test-langchain.ts 533 B

12345678910111213141516171819202122
  1. import { ChatOpenAI } from '@langchain/openai';
  2. const model = new ChatOpenAI({
  3. model: 'qwen3.6-plus',
  4. apiKey: 'sk-c25679401ba24c749f53be86b0c9a7a6',
  5. configuration: {
  6. baseURL: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
  7. },
  8. temperature: 0.7,
  9. });
  10. async function test() {
  11. console.log('Testing LangChain with qwen3.6-plus...');
  12. try {
  13. const result = await model.invoke('你是谁?');
  14. console.log('Result:', result.content);
  15. } catch (e: any) {
  16. console.error('Error:', e.message);
  17. }
  18. }
  19. test();