feat: solution for 'Экзамен: Самокорректирующийся агент'
This commit is contained in:
+17
-15
@@ -1,18 +1,20 @@
|
||||
import Graph from './graph.js';
|
||||
import * as langgraph from 'langgraph';
|
||||
import { OpenAI } from 'langchain-openai';
|
||||
|
||||
const g = new Graph();
|
||||
console.log('langgraph module loaded:', typeof langgraph);
|
||||
console.log('OpenAI class loaded:', typeof OpenAI);
|
||||
|
||||
g.addNode('A');
|
||||
g.addNode('B');
|
||||
g.addNode('C');
|
||||
const llm = new OpenAI({
|
||||
apiKey: process.env.OPENAI_API_KEY || '',
|
||||
modelName: 'gpt-3.5-turbo',
|
||||
});
|
||||
|
||||
g.addEdge('A', 'B');
|
||||
g.addEdge('B', 'C');
|
||||
|
||||
console.log('Before reflexive:');
|
||||
console.log(g.getAdjacencyList());
|
||||
|
||||
g.reflexive();
|
||||
|
||||
console.log('After reflexive:');
|
||||
console.log(g.getAdjacencyList());
|
||||
(async () => {
|
||||
const prompt = 'Hello, world!';
|
||||
try {
|
||||
const response = await llm.invoke(prompt);
|
||||
console.log('LLM response:', response);
|
||||
} catch (error) {
|
||||
console.error('Error invoking LLM:', error);
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user