Spaces:
Sleeping
Sleeping
Update functions_hf.py
Browse files- functions_hf.py +16 -1
functions_hf.py
CHANGED
|
@@ -5,8 +5,23 @@ from langchain_core.output_parsers import StrOutputParser
|
|
| 5 |
from langchain_core.runnables import RunnablePassthrough
|
| 6 |
import re
|
| 7 |
from typing import Dict, List
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
llm = HuggingFaceHub(repo_id="Qwen/Qwen2.5-72B-Instruct", model_kwargs={"temperature":0, "max_length":64})
|
| 10 |
|
| 11 |
# Initialize database connection
|
| 12 |
db = SQLDatabase.from_uri("sqlite:///Spring_2025_courses.db", sample_rows_in_table_info=0)
|
|
|
|
| 5 |
from langchain_core.runnables import RunnablePassthrough
|
| 6 |
import re
|
| 7 |
from typing import Dict, List
|
| 8 |
+
import os
|
| 9 |
+
from dotenv import load_dotenv
|
| 10 |
+
|
| 11 |
+
load_dotenv()
|
| 12 |
+
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
| 13 |
+
|
| 14 |
+
from langchain_openai import ChatOpenAI
|
| 15 |
+
|
| 16 |
+
llm = ChatOpenAI(
|
| 17 |
+
model="gpt-4o",
|
| 18 |
+
temperature=0,
|
| 19 |
+
max_tokens=None,
|
| 20 |
+
timeout=None,
|
| 21 |
+
max_retries=2,
|
| 22 |
+
api_key=OPENAI_API_KEY, # if you prefer to pass api key in directly instaed of using env vars
|
| 23 |
+
)
|
| 24 |
|
|
|
|
| 25 |
|
| 26 |
# Initialize database connection
|
| 27 |
db = SQLDatabase.from_uri("sqlite:///Spring_2025_courses.db", sample_rows_in_table_info=0)
|