fix openai env vars

This commit is contained in:
Ajay Raj 2023-03-28 11:08:19 -07:00
commit 389e2b2515
4 changed files with 9 additions and 4 deletions

View file

@ -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]

View file

@ -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

View file

@ -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 = (