sja820 commited on
Commit
3bfa76c
·
verified ·
1 Parent(s): 9d014b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -51
app.py CHANGED
@@ -5,39 +5,6 @@ co=cohere.Client("")
5
 
6
 
7
 
8
- def study_chat_v2(menu, user_input):
9
- menu=input("Select what type of help you what from the model: 1. generate practice problems 2. correct the practice problems 3.explain practice problems ")
10
- # get user input
11
- if menu == "1":
12
- #vocab= input("Enter in your vocab list: ")
13
- message= f"Given this vocab list {user_input}, generate a moderately challenging practice sentences in spanish wiht different tenses where i have to fill in the correct verb in the correct tense"
14
-
15
- elif menu== "2":
16
- #answers=input("Enter your answers: ")
17
- message= f'Correct my answers by telling me how many and which ones I missed {user_input}'
18
-
19
- elif menu== "3":
20
- #answers=input("Provide an explanation for this word and why you conjugated it like this: ")
21
- message=f'Provide an explanation for this word and why you conjugated it like this: {user_input}'
22
- #message = input("Send the model a message: ")
23
-
24
- print(message)
25
- # generate a response with the current chat history
26
- response = co.chat(
27
- message=message,
28
- temperature=0.3,
29
- chat_history=chat_history
30
- )
31
- answer = response.text
32
- # add message and answer to the chat history
33
- user_message = {"role": "USER", "text": message}
34
- bot_message = {"role": "CHATBOT", "text": answer}
35
-
36
- chat_history.append(user_message)
37
- chat_history.append(bot_message)
38
-
39
- return response.text
40
-
41
  def study_chat(menu, user_input):
42
  co = cohere.Client(
43
  api_key="vlXYTrmx36dpDUO2CJOECuFxm1tswqLUD22tRd9w", # This is your trial API key
@@ -98,28 +65,27 @@ gr.__version__
98
  import logging
99
  logging.basicConfig(level=logging.DEBUG)
100
 
101
- def interface(user_input):
102
- menu = "1" # Or another default/selected value
103
  answer = study_chat(menu, user_input)
104
  return answer
105
 
106
- iface = gr.Interface(
107
- fn=interface,
108
- inputs=gr.Textbox(lines=2, placeholder="Enter your input here..."),
109
- outputs="text",
110
- description="Select what type of help you want from the model: 1. generate practice problems 2. correct the practice problems 3. explain practice problems"
111
- )
 
112
 
113
- iface.launch()
114
  # # Define the Gradio interface
115
- # with gr.Blocks() as demo:
116
- # gr.Markdown("# Spanish Study Tool")
117
- # menu = gr.Dropdown(choices=["1", "2", "3"], label="Select what type of help you want from the model \n 1: Generate Practice Sentences, 2: Correct my answers , 3: Explain sentence")
118
- # user_input = gr.Textbox(label="Enter your vocab list or answers", placeholder="Type here...")
119
- # output = gr.Textbox(label="Model Response")
120
- # #history_state = gr.State([]) # To store chat history
121
 
122
- # button = gr.Button("Submit")
123
- # button.click(interface, inputs=[menu, user_input], outputs=[output])
124
 
125
- # demo.launch(debug=True, share=True)
 
5
 
6
 
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  def study_chat(menu, user_input):
9
  co = cohere.Client(
10
  api_key="vlXYTrmx36dpDUO2CJOECuFxm1tswqLUD22tRd9w", # This is your trial API key
 
65
  import logging
66
  logging.basicConfig(level=logging.DEBUG)
67
 
68
+ def interface(menu,user_input):
 
69
  answer = study_chat(menu, user_input)
70
  return answer
71
 
72
+ # iface = gr.Interface(
73
+ # fn=interface,
74
+ # inputs=gr.Textbox(lines=2, placeholder="Enter your input here..."),
75
+ # outputs="text",
76
+ # description="Select what type of help you want from the model: 1. generate practice problems 2. correct the practice problems 3. explain practice problems"
77
+ # )
78
+
79
 
 
80
  # # Define the Gradio interface
81
+ with gr.Blocks() as demo:
82
+ gr.Markdown("# Spanish Study Tool")
83
+ menu = gr.Dropdown(choices=["1", "2", "3"], label="Select what type of help you want from the model \n 1: Generate Practice Sentences, 2: Correct my answers , 3: Explain sentence")
84
+ user_input = gr.Textbox(label="Enter your vocab list or answers", placeholder="Type here...")
85
+ output = gr.Textbox(label="Model Response")
86
+ #history_state = gr.State([]) # To store chat history
87
 
88
+ button = gr.Button("Submit")
89
+ button.click(interface, inputs=[menu, user_input], outputs=[output])
90
 
91
+ demo.launch(debug=True, share=True)