Skip to content

Commit

Permalink
feat: add embedding func
Browse files Browse the repository at this point in the history
  • Loading branch information
MarleneJiang committed Aug 9, 2023
1 parent b65bdd1 commit 8ddd168
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

## 🎨 技术栈

- openai
- Openai
- Jest
- Typescript
- Vitepress
Expand Down
9 changes: 9 additions & 0 deletions package/agents/teacherAgents/__tests__/agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@ if (!res.success) {
console.log(res.data);
}
debugger;

// system : You are an article polishing teacher, the main task is polishing PPT speech draft.I'll give you a speech, you need to polish it up. Ensure the consistency, logic and grammatical correctness of the speech. Please use Encouraging language to fully reflect the brief nature of the PPT presentation. Whatever I offer, I must answer in Chinese. After answering, please make an objective evaluation of the results. The rating items are [audience_understandability,logicality]Finally, according to the score and results, the next improvement suggestions are given.

// user:
// 你好,非常欢迎你来到我身边~我是xxx,我会把最美好的一面呈现给你!

// assistant: {"name":"result_evaluation","arguments":"{\n \"polished_result\": \"你好,非常欢迎你来到我身边!我是xxx,我将为你展示我最美好的一面!\",\n \"audience_understandability\": 90,\n \"logicality\": 90,\n \"suggestion\": \"no suggestion\"\n } "}

// {polished_result: '你好,非常欢迎你来到我身边!我是xxx,我将为你展示我最美好的一面!', audience_understandability: 90, logicality: 90, suggestion: 'no suggestion'}
10 changes: 10 additions & 0 deletions package/utils/openai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ export class LLM {
});
}

async embedding(
input: string | string[] | number[] | number[][],
): Promise<OpenAI.Embedding> {
return await this.llm.embeddings.create({
input: input,
model: "text-embedding-ada-002",
user: "GWT",
});
}

printMessage(
resMessages: OpenAI.Chat.Completions.ChatCompletion.Choice[],
reqMessages?: OpenAI.Chat.CompletionCreateParams.CreateChatCompletionRequestNonStreaming.Message[],
Expand Down

0 comments on commit 8ddd168

Please sign in to comment.