Files
django-vue3-admin-gd/chat/services/chat_service.py
2025-07-17 10:59:48 +08:00

15 lines
399 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# LangChain集成示例
from langchain_openai import OpenAI
from dotenv import load_dotenv
load_dotenv()
class ChatService:
def __init__(self):
# 这里以OpenAI为例实际可根据需要配置
self.llm = OpenAI(temperature=0.7, api_key='sssss')
def chat(self, prompt: str) -> str:
# 简单调用LLM
return self.llm(prompt)
chat_service = ChatService()