feat: 简单对话
This commit is contained in:
parent
c60f157b6f
commit
1accefc1da
20
src/index.ts
20
src/index.ts
@ -1 +1,19 @@
|
|||||||
console.log("Hello, LLM to Agent!");
|
import OpenAI from 'openai';
|
||||||
|
import 'dotenv/config';
|
||||||
|
|
||||||
|
const client = new OpenAI({
|
||||||
|
apiKey: process.env.OPENAI_API_KEY,
|
||||||
|
baseURL: process.env.OPENAI_BASE_URL,
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await client.chat.completions.create({
|
||||||
|
model: 'deepseek-v4-pro',
|
||||||
|
messages: [
|
||||||
|
{ role: 'system', content: '你是一个直爽的编程助手,回答尽量简洁。' },
|
||||||
|
{ role: 'user', content: '什么是闭包?用一句话解释。' },
|
||||||
|
],
|
||||||
|
temperature: 0.7,
|
||||||
|
});
|
||||||
|
|
||||||
|
const reply = response.choices[0]?.message?.content;
|
||||||
|
console.log(reply);
|
||||||
Loading…
x
Reference in New Issue
Block a user