Spaces:
Running
Running
Commit
·
fa174ea
1
Parent(s):
e384081
NRP model
Browse files- app/app.py +5 -2
- app/system_prompt.txt +9 -1
app/app.py
CHANGED
@@ -148,8 +148,10 @@ with open('app/system_prompt.txt', 'r') as file:
|
|
148 |
|
149 |
from langchain_openai import ChatOpenAI
|
150 |
|
151 |
-
llm = ChatOpenAI(model = "kosbu/Llama-3.3-70B-Instruct-AWQ", api_key="cirrus-vllm-secret-api-key", base_url = "https://llm.cirrus.carlboettiger.info/v1/", temperature=0)
|
152 |
# llm = ChatOpenAI(model="gpt-4", temperature=0)
|
|
|
|
|
153 |
|
154 |
managers = ca.sql("SELECT DISTINCT manager FROM mydata;").execute()
|
155 |
names = ca.sql("SELECT name FROM mydata GROUP BY name HAVING SUM(acres) >10000;").execute()
|
@@ -181,7 +183,6 @@ def run_sql(query,color_choice):
|
|
181 |
output = few_shot_structured_llm.invoke(query)
|
182 |
sql_query = output.sql_query
|
183 |
explanation =output.explanation
|
184 |
-
|
185 |
if not sql_query: # if the chatbot can't generate a SQL query.
|
186 |
st.success(explanation)
|
187 |
return pd.DataFrame({'id' : []})
|
@@ -272,6 +273,8 @@ with st.container():
|
|
272 |
key: (True if key in cols else value)
|
273 |
for key, value in chatbot_toggles.items()
|
274 |
}
|
|
|
|
|
275 |
else:
|
276 |
ids = []
|
277 |
except Exception as e:
|
|
|
148 |
|
149 |
from langchain_openai import ChatOpenAI
|
150 |
|
151 |
+
# llm = ChatOpenAI(model = "kosbu/Llama-3.3-70B-Instruct-AWQ", api_key="cirrus-vllm-secret-api-key", base_url = "https://llm.cirrus.carlboettiger.info/v1/", temperature=0)
|
152 |
# llm = ChatOpenAI(model="gpt-4", temperature=0)
|
153 |
+
llm = ChatOpenAI(model = "llama3", api_key=st.secrets['NRP_API_KEY'], base_url = "https://llm.nrp-nautilus.io/", temperature=0)
|
154 |
+
|
155 |
|
156 |
managers = ca.sql("SELECT DISTINCT manager FROM mydata;").execute()
|
157 |
names = ca.sql("SELECT name FROM mydata GROUP BY name HAVING SUM(acres) >10000;").execute()
|
|
|
183 |
output = few_shot_structured_llm.invoke(query)
|
184 |
sql_query = output.sql_query
|
185 |
explanation =output.explanation
|
|
|
186 |
if not sql_query: # if the chatbot can't generate a SQL query.
|
187 |
st.success(explanation)
|
188 |
return pd.DataFrame({'id' : []})
|
|
|
273 |
key: (True if key in cols else value)
|
274 |
for key, value in chatbot_toggles.items()
|
275 |
}
|
276 |
+
for key, value in chatbot_toggles.items():
|
277 |
+
st.session_state[key] = value # Update session state
|
278 |
else:
|
279 |
ids = []
|
280 |
except Exception as e:
|
app/system_prompt.txt
CHANGED
@@ -160,5 +160,13 @@ sql_query:
|
|
160 |
SELECT SUM("fire" * "acres") / SUM("acres") * 100 AS percent_fire
|
161 |
FROM mydata
|
162 |
WHERE "status" = '30x30-conserved';
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
Question: {input}
|
|
|
160 |
SELECT SUM("fire" * "acres") / SUM("acres") * 100 AS percent_fire
|
161 |
FROM mydata
|
162 |
WHERE "status" = '30x30-conserved';
|
163 |
+
|
164 |
+
## Example:
|
165 |
+
example_user: "Show me all land managed by the United States Forest Service"
|
166 |
+
sql_query:
|
167 |
+
SELECT "id", "geom", "name", "acres", "manager" FROM mydata
|
168 |
+
WHERE LOWER("manager") LIKE '%united states forest service%';
|
169 |
+
|
170 |
+
|
171 |
+
|
172 |
Question: {input}
|