api key configs
This commit is contained in:
parent
7202a82923
commit
dfb249e13d
5 changed files with 29 additions and 15 deletions
|
|
@ -1,4 +1,6 @@
|
|||
import os
|
||||
from typing import Optional
|
||||
import openai
|
||||
from langchain.prompts import (
|
||||
ChatPromptTemplate,
|
||||
MessagesPlaceholder,
|
||||
|
|
@ -16,12 +18,16 @@ class ChatGPTAgent(BaseAgent):
|
|||
def __init__(
|
||||
self,
|
||||
system_prompt: str,
|
||||
api_key: Optional[str] = None,
|
||||
initial_message: Optional[str] = None,
|
||||
model_name: str = "gpt-3.5-turbo",
|
||||
temperature: float = 0.7,
|
||||
max_tokens: int = 100,
|
||||
):
|
||||
super().__init__(initial_message=initial_message)
|
||||
openai.api_key = os.getenv("OPENAI_API_KET", api_key)
|
||||
if not openai.api_key:
|
||||
raise ValueError("OpenAI API key not provided")
|
||||
self.prompt = ChatPromptTemplate.from_messages(
|
||||
[
|
||||
SystemMessagePromptTemplate.from_template(system_prompt),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue