fix openai env vars
This commit is contained in:
parent
db9afd4544
commit
389e2b2515
4 changed files with 9 additions and 4 deletions
|
|
@ -3,6 +3,8 @@ from langchain.llms import OpenAI
|
|||
from langchain.prompts import PromptTemplate
|
||||
from pydantic import BaseModel
|
||||
|
||||
from vocode import getenv
|
||||
|
||||
TEMPLATE = """
|
||||
Read the following conversation classify the final emotion of the Bot as one of [{emotions}].
|
||||
Output the degree of emotion as a value between 0 and 1 in the format EMOTION,DEGREE: ex. {example_emotion},0.5
|
||||
|
|
@ -22,7 +24,7 @@ class BotSentimentAnalyser:
|
|||
def __init__(self, emotions: list[str], model_name: str = "text-davinci-003"):
|
||||
self.model_name = model_name
|
||||
self.llm = OpenAI(
|
||||
model_name=self.model_name,
|
||||
model_name=self.model_name, openai_api_key=getenv("OPENAI_API_KEY")
|
||||
)
|
||||
assert len(emotions) > 0
|
||||
self.emotions = [e.lower() for e in emotions]
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ class ChatGPTAgent(BaseAgent):
|
|||
model_name=self.agent_config.model_name,
|
||||
temperature=self.agent_config.temperature,
|
||||
max_tokens=self.agent_config.max_tokens,
|
||||
openai_api_key=openai.api_key,
|
||||
)
|
||||
self.conversation = ConversationChain(
|
||||
memory=self.memory, prompt=self.prompt, llm=self.llm
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ from langchain import OpenAI
|
|||
from langchain.llms import OpenAIChat
|
||||
from typing import Generator
|
||||
import logging
|
||||
from vocode import getenv
|
||||
|
||||
from vocode.streaming.agent.base_agent import BaseAgent
|
||||
from vocode.streaming.agent.utils import stream_llm_response
|
||||
|
|
@ -43,6 +44,7 @@ class LLMAgent(BaseAgent):
|
|||
model_name=self.agent_config.model_name,
|
||||
temperature=self.agent_config.temperature,
|
||||
max_tokens=self.agent_config.max_tokens,
|
||||
openai_api_key=getenv("OPENAI_API_KEY"),
|
||||
)
|
||||
self.stop_tokens = [f"{recipient}:"]
|
||||
self.first_response = (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue