Skip to content

Commit

Permalink
Merge pull request #288 from isamu/groqType2
Browse files Browse the repository at this point in the history
more type
  • Loading branch information
snakajima authored May 9, 2024
2 parents 386549d + f12bc2f commit 0fcc013
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/experimental_agents/llm_agents/groq_agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ export const groqAgent: AgentFunction<
query?: string;
system?: string;
verbose?: boolean;
tools?: Record<string, Groq.Chat.CompletionCreateParams.ToolChoice>;
tools?: Record<string, Groq.Chat.CompletionCreateParams.Tool>;
temperature?: number;
max_tokens?: number;
tool_choice?: string | Record<string, any>;
tool_choice?: string | Record<string, Groq.Chat.CompletionCreateParams.ToolChoice>;
},
Record<string, any> | string,
Groq.Chat.ChatCompletion,
string | Array<Groq.Chat.CompletionCreateParams.Message>
> = async ({ params, inputs }) => {
assert(groq !== undefined, "The GROQ_API_KEY environment variable is missing.");
const { verbose, query, system, tools, tool_choice, max_tokens, temperature } = params;
const [input_query, previous_messages] = inputs;

// Notice that we ignore params.system if previous_message exists.
const messages: Array<any> = previous_messages && Array.isArray(previous_messages) ? previous_messages : system ? [{ role: "system", content: system }] : [];
const messages: Array<Groq.Chat.CompletionCreateParams.Message> = previous_messages && Array.isArray(previous_messages) ? previous_messages : system ? [{ role: "system", content: system }] : [];

const content = (query ? [query] : []).concat(input_query ? [input_query as string] : []).join("\n");
const content = (query ? [query] : []).concat(input_query && typeof input_query === "string" ? [input_query] : []).join("\n");
if (content) {
messages.push({
role: "user",
Expand Down

0 comments on commit 0fcc013

Please sign in to comment.