Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Participant #526

Merged
merged 14 commits into from
Jun 10, 2024
22 changes: 17 additions & 5 deletions docs/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 17 additions & 5 deletions genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/core/src/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ export async function executeChatSession(
functions: ChatFunctionCallback[],
schemas: Record<string, JSONSchema>,
completer: ChatCompletionHandler,
chatParticipants: ChatParticipantHandler[],
pelikhan marked this conversation as resolved.
Show resolved Hide resolved
pelikhan marked this conversation as resolved.
Show resolved Hide resolved
pelikhan marked this conversation as resolved.
Show resolved Hide resolved
genOptions: GenerationOptions
pelikhan marked this conversation as resolved.
Show resolved Hide resolved
pelikhan marked this conversation as resolved.
Show resolved Hide resolved
) {
const {
Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/expander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ async function callExpander(
let functions: ChatFunctionCallback[] = []
let fileMerges: FileMergeHandler[] = []
let outputProcessors: PromptOutputProcessorHandler[] = []
let chatParticipants: ChatParticipantHandler[] = []
pelikhan marked this conversation as resolved.
Show resolved Hide resolved
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The chatParticipants parameter should be placed after aici to match the order in the function signature.

generated by genaiscript pr-review-commit

pelikhan marked this conversation as resolved.
Show resolved Hide resolved
let aici: AICIRequest

const logCb = (msg: any) => {
Expand Down Expand Up @@ -139,6 +140,7 @@ async function callExpander(
functions: fns,
fileMerges: fms,
outputProcessors: ops,
chatParticipants: cps,
} = await renderPromptNode(model, node, { trace })
text = prompt
assistantText = assistantPrompt
Expand All @@ -147,6 +149,7 @@ async function callExpander(
functions = fns
fileMerges = fms
outputProcessors = ops
chatParticipants = cps
if (errors?.length) {
for (const error of errors) trace.error(``, error)
status = "error"
Expand Down Expand Up @@ -182,6 +185,7 @@ async function callExpander(
functions,
fileMerges,
outputProcessors,
chatParticipants,
aici,
}
}
Expand Down Expand Up @@ -313,6 +317,7 @@ export async function expandTemplate(
const functions = prompt.functions
const fileMerges = prompt.fileMerges
const outputProcessors = prompt.outputProcessors
const chatParticipants = prompt.chatParticipants

if (prompt.logs?.length) trace.details("📝 console.log", prompt.logs)
if (prompt.text) {
Expand Down Expand Up @@ -361,6 +366,7 @@ export async function expandTemplate(
if (sysr.functions) functions.push(...sysr.functions)
if (sysr.fileMerges) fileMerges.push(...sysr.fileMerges)
if (sysr.outputProcessors) outputProcessors.push(...outputProcessors)
if (sysr.chatParticipants) chatParticipants.push(...chatParticipants)
if (sysr.logs?.length) trace.details("📝 console.log", sysr.logs)
if (sysr.text) {
systemMessage.content += SYSTEM_FENCE + "\n" + sysr.text + "\n"
Expand Down Expand Up @@ -434,5 +440,6 @@ ${schemaTs}
responseSchema,
fileMerges,
outputProcessors,
chatParticipants,
}
}
22 changes: 17 additions & 5 deletions packages/core/src/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/core/src/promptcontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { readText } from "./fs"
import {
PromptNode,
appendChild,
createChatParticipant,
createFileMergeNode,
createImageNode,
createOutputProcessor,
Expand Down Expand Up @@ -169,6 +170,10 @@ export function createPromptContext(
if (fn) appendPromptChild(createOutputProcessor(fn))
}

const defChatParticipant = (participant: ChatParticipantHandler) => {
if (participant) appendPromptChild(createChatParticipant(participant))
}
pelikhan marked this conversation as resolved.
Show resolved Hide resolved
pelikhan marked this conversation as resolved.
Show resolved Hide resolved
pelikhan marked this conversation as resolved.
Show resolved Hide resolved
pelikhan marked this conversation as resolved.
Show resolved Hide resolved
pelikhan marked this conversation as resolved.
Show resolved Hide resolved
pelikhan marked this conversation as resolved.
Show resolved Hide resolved

const promptHost: PromptHost = {
askUser: (question) =>
host.askUser({
Expand Down Expand Up @@ -204,6 +209,7 @@ export function createPromptContext(
retrieval,
host: promptHost,
defOutputProcessor,
defChatParticipant,
defFileMerge: (fn) => {
appendPromptChild(createFileMergeNode(fn))
},
Expand Down
Loading
Loading