Tonic commited on
Commit
c224872
1 Parent(s): 05b9190

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -47,11 +47,7 @@ def ask_openai(question):
47
  if not response_received:
48
  return "Response timed out."
49
 
50
- steps = client.beta.threads.runs.steps.list(
51
- thread_id=thread.id,
52
- run_id=run.id
53
- )
54
-
55
  if steps.data:
56
  last_step = steps.data[-1]
57
  if last_step.type == 'message_creation':
@@ -61,9 +57,17 @@ def ask_openai(question):
61
  message_id=message_id
62
  )
63
  if message.content and message.content[0].type == 'text':
64
- return message.content[0].text.value
65
- return "No response."
66
-
 
 
 
 
 
 
 
 
67
  except Exception as e:
68
  return f"An error occurred: {str(e)}"
69
 
@@ -71,8 +75,8 @@ iface = gr.Interface(
71
  fn=ask_openai,
72
  inputs=gr.Textbox(lines=5, placeholder="Hi there, I have a plant that's..."),
73
  outputs=gr.Markdown(),
74
- title="Wecome to Tonic's Bulbi Plant Doctor",
75
- description="""Introduce your plant below. Be as descriptive as possible. Respond with additional information when prompted. Save your plants with Bulbi Plant Doctor""",
76
  examples=examples
77
  )
78
 
 
47
  if not response_received:
48
  return "Response timed out."
49
 
50
+ response_text = "No response."
 
 
 
 
51
  if steps.data:
52
  last_step = steps.data[-1]
53
  if last_step.type == 'message_creation':
 
57
  message_id=message_id
58
  )
59
  if message.content and message.content[0].type == 'text':
60
+ response_text = message.content[0].text.value
61
+
62
+ gradio_client = Client("https://tonic1-tulu.hf.space/--replicas/9sffh/")
63
+ final_result = gradio_client.predict(
64
+ response_text,
65
+ "I am Tulu, an Expert Plant Doctor, i provide plant assessments. Please tell me more about your situation.",
66
+ 1300, 0.4, 0.9, 0.9, False, fn_index=0
67
+ )
68
+
69
+ return final_result
70
+
71
  except Exception as e:
72
  return f"An error occurred: {str(e)}"
73
 
 
75
  fn=ask_openai,
76
  inputs=gr.Textbox(lines=5, placeholder="Hi there, I have a plant that's..."),
77
  outputs=gr.Markdown(),
78
+ title="Wecome to Tonic's Bulbi-Tulu Plant Doctor",
79
+ description="""Welcome to Bulbi using [Tulu](https://huggingface.co/allenai/tulu-2-dpo-70b). Introduce your plant below. Be as descriptive as possible. Respond with additional information when prompted. Save your plants with Tulu Plant Doctor""",
80
  examples=examples
81
  )
82