jianghuyihei commited on
Commit
1b42af4
1 Parent(s): 1099179
Files changed (2) hide show
  1. LLM.py +10 -14
  2. agents.py +5 -5
LLM.py CHANGED
@@ -56,27 +56,23 @@ class base_llm:
56
 
57
 
58
  class openai_llm(base_llm):
59
- def __init__(self,model = "gpt4o-0513",deployment = "gpt-4o-0806") -> None:
60
  super().__init__()
61
  self.model = model
62
- if "AZURE_OPENAI_ENDPOINT" not in os.environ or os.environ["AZURE_OPENAI_ENDPOINT"] == "":
63
- raise ValueError("AZURE_OPENAI_ENDPOINT is not set")
64
- if "AZURE_OPENAI_KEY" not in os.environ or os.environ["AZURE_OPENAI_KEY"] == "":
65
- raise ValueError("AZURE_OPENAI_KEY is not set")
66
 
67
- api_version = os.environ.get("AZURE_OPENAI_API_VERSION",None)
68
  if api_version == "":
69
  api_version = None
70
  self.client = AzureOpenAI(
71
  azure_deployment= deployment,
72
- azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
73
- api_key=os.environ["AZURE_OPENAI_KEY"],
74
  api_version= api_version
75
  )
76
  self.async_client = AsyncAzureOpenAI(
77
  azure_deployment= deployment,
78
- azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
79
- api_key=os.environ["AZURE_OPENAI_KEY"],
80
  api_version= api_version
81
  )
82
 
@@ -114,8 +110,8 @@ class openai_llm(base_llm):
114
  client = AzureOpenAI(
115
  azure_endpoint=os.environ.get("EMBEDDING_API_ENDPOINT",None),
116
  api_key=os.environ.get("EMBEDDING_API_KEY",None),
117
- api_version= os.environ.get("AZURE_OPENAI_API_VERSION",None),
118
- azure_deployment="embedding-3-large"
119
  )
120
  else:
121
  client = self.client
@@ -143,8 +139,8 @@ class openai_llm(base_llm):
143
  async_client = AsyncAzureOpenAI(
144
  azure_endpoint=os.environ.get("EMBEDDING_API_ENDPOINT",None),
145
  api_key=os.environ.get("EMBEDDING_API_KEY",None),
146
- api_version= os.environ.get("AZURE_OPENAI_API_VERSION",None),
147
- azure_deployment="embedding-3-large"
148
  )
149
  else:
150
  async_client = self.async_client
 
56
 
57
 
58
  class openai_llm(base_llm):
59
+ def __init__(self,model = None,deployment = None,endpoint=None,api_key = None) -> None:
60
  super().__init__()
61
  self.model = model
 
 
 
 
62
 
63
+ api_version= "2024-02-15-preview"
64
  if api_version == "":
65
  api_version = None
66
  self.client = AzureOpenAI(
67
  azure_deployment= deployment,
68
+ azure_endpoint=endpoint,
69
+ api_key=api_key,
70
  api_version= api_version
71
  )
72
  self.async_client = AsyncAzureOpenAI(
73
  azure_deployment= deployment,
74
+ azure_endpoint=endpoint,
75
+ api_key=api_key,
76
  api_version= api_version
77
  )
78
 
 
110
  client = AzureOpenAI(
111
  azure_endpoint=os.environ.get("EMBEDDING_API_ENDPOINT",None),
112
  api_key=os.environ.get("EMBEDDING_API_KEY",None),
113
+ api_version= "2024-02-15-preview",
114
+ azure_deployment="text-embedding-3-large"
115
  )
116
  else:
117
  client = self.client
 
139
  async_client = AsyncAzureOpenAI(
140
  azure_endpoint=os.environ.get("EMBEDDING_API_ENDPOINT",None),
141
  api_key=os.environ.get("EMBEDDING_API_KEY",None),
142
+ api_version= "2024-02-15-preview",
143
+ azure_deployment="text-embedding-3-large"
144
  )
145
  else:
146
  async_client = self.async_client
agents.py CHANGED
@@ -4,14 +4,14 @@ from searcher import Result,SementicSearcher
4
  from LLM import openai_llm
5
  from prompts import *
6
  from utils import extract
 
7
 
8
-
9
- def get_llm(model = "gpt-4o-0806",deployment = "gpt-4o-0806"):
10
- return openai_llm(model,deployment)
11
 
12
  def get_llms():
13
- main_llm = get_llm("gpt4o (08-06)","gpt-4o-0806")
14
- cheap_llm = get_llm("gpt-4o-mini (0718)","gpt-4o-mini-0718")
15
  return main_llm,cheap_llm
16
 
17
  def judge_idea(i,j,idea0,idea1,topic,llm):
 
4
  from LLM import openai_llm
5
  from prompts import *
6
  from utils import extract
7
+ import os
8
 
9
+ def get_llm(model,deployment ,endpoint,api_key):
10
+ return openai_llm(model,deployment,endpoint,api_key)
 
11
 
12
  def get_llms():
13
+ main_llm = get_llm("gpt4o (05-13)","gpt-4o-0513",os.environ.get("AZURE_OPENAI_API_ENDPOINT",None),os.environ.get("AZURE_OPENAI_API",None))
14
+ cheap_llm = get_llm("gpt-4o-mini (0718)","gpt-4o-mini-0718",os.environ.get("CHEAP_AZURE_OPENAI_API_ENDPOINT",None),os.environ.get("CHEAP_AZURE_OPENAI_API",None))
15
  return main_llm,cheap_llm
16
 
17
  def judge_idea(i,j,idea0,idea1,topic,llm):