BaRiDo commited on
Commit
b647859
·
verified ·
1 Parent(s): 45ab87d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -41,13 +41,13 @@ def IBM_token():
41
  st.session_state.IBM_ACCESS_TOKEN = response.json().get("access_token", "")
42
 
43
 
44
- def IBM_chat (messages):
45
  body = {
46
  "model_id": "ibm/granite-3-8b-instruct",
47
  "project_id": os.getenv("IBM_PROJECT_ID"),
48
  "messages": messages,
49
  "max_tokens": 10000,
50
- "temperature": 0.7,
51
  "time_limit": 40000
52
  }
53
  headers = {
@@ -67,9 +67,9 @@ def IBM_chat (messages):
67
  response = response.json()
68
  return response["choices"][0]["message"]["content"]
69
 
70
- def IBM_query (prompt):
71
  messages = [{"role": "user", "content": prompt}]
72
- return IBM_chat(messages)
73
 
74
  def get_credentials():
75
  return {
@@ -198,7 +198,7 @@ def do_query(query):
198
 
199
  # Get response from IBM
200
  with st.spinner("Thinking..."):
201
- assistant_reply = IBM_chat(messages)
202
 
203
  # Display assistant message
204
  st.chat_message("assistant").markdown(assistant_reply)
@@ -258,8 +258,8 @@ if st.sidebar.button("🔗 Analyze with IBM Granite"):
258
  prompt = f"Define search criteria for projects to implement: {policy_input}"
259
 
260
  # Get response from IBM
261
- with st.spinner("Analyzing..."):
262
- result = IBM_query(prompt)
263
  st.session_state["extended_query"] = "Find 3 projects that best match these criteria: " + result
264
  else:
265
  st.sidebar.warning("Please enter a policy or business idea first!")
 
41
  st.session_state.IBM_ACCESS_TOKEN = response.json().get("access_token", "")
42
 
43
 
44
+ def IBM_chat (messages, temperature = 0.7):
45
  body = {
46
  "model_id": "ibm/granite-3-8b-instruct",
47
  "project_id": os.getenv("IBM_PROJECT_ID"),
48
  "messages": messages,
49
  "max_tokens": 10000,
50
+ "temperature": temperature
51
  "time_limit": 40000
52
  }
53
  headers = {
 
67
  response = response.json()
68
  return response["choices"][0]["message"]["content"]
69
 
70
+ def IBM_query (prompt, temperature = 0.7):
71
  messages = [{"role": "user", "content": prompt}]
72
+ return IBM_chat(messages, temperature)
73
 
74
  def get_credentials():
75
  return {
 
198
 
199
  # Get response from IBM
200
  with st.spinner("Thinking..."):
201
+ assistant_reply = IBM_chat(messages, 0) ## no creativity here, just searching
202
 
203
  # Display assistant message
204
  st.chat_message("assistant").markdown(assistant_reply)
 
258
  prompt = f"Define search criteria for projects to implement: {policy_input}"
259
 
260
  # Get response from IBM
261
+ with st.sidebar.spinner("Analyzing..."):
262
+ result = IBM_query(prompt, 0.7)
263
  st.session_state["extended_query"] = "Find 3 projects that best match these criteria: " + result
264
  else:
265
  st.sidebar.warning("Please enter a policy or business idea first!")