muzammil-eds commited on
Commit
acec76c
1 Parent(s): f8f0622

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -19
app.py CHANGED
@@ -9,29 +9,17 @@ from langchain.llms.base import LLM
9
  from typing import Optional, List
10
  import g4f
11
 
12
- class FinLLM(LLM):
13
 
14
- @property
15
- def _llm_type(self) -> str:
16
- return "custom"
17
 
18
- def _call(self, prompt: str, stop: Optional[List[str]] = None) -> str:
19
- out = g4f.ChatCompletion.create(
20
- model="gpt-3.5-turbo",
21
- messages=[{"role": "user", "content": prompt}],
22
- temperature=0.5, # You can adjust parameters as needed
23
- max_tokens=350 # Adjust the token limit as needed
24
- ) #
25
- if stop:
26
- stop_indexes = (out.find(s) for s in stop if s in out)
27
- min_stop = min(stop_indexes, default=-1)
28
- if min_stop > -1:
29
- out = out[:min_stop]
30
- return out
31
 
32
 
33
- llm = FinLLM()
34
-
35
 
36
  def init_ses_states():
37
  st.session_state.setdefault('chat_history', [])
 
9
  from typing import Optional, List
10
  import g4f
11
 
12
+ os.environ['OPENAI_API_KEY'] = os.getenv('OPENAI_API_KEY')
13
 
14
+ print("API Key:", OPENAI_API_KEY)
 
 
15
 
16
+ llm = ChatOpenAI(
17
+ model='gpt-3.5-turbo',
18
+ max_tokens=500,
19
+ temperature=0.7,
20
+ )
 
 
 
 
 
 
 
 
21
 
22
 
 
 
23
 
24
  def init_ses_states():
25
  st.session_state.setdefault('chat_history', [])