steve7909 commited on
Commit
4bd2a98
1 Parent(s): 69ce671

added intro message

Browse files
Files changed (2) hide show
  1. anki_japanese_english_pairs.csv +1 -1
  2. app.py +22 -7
anki_japanese_english_pairs.csv CHANGED
@@ -1843,7 +1843,7 @@ A: 日本は人が多いねえ。 B: うん、何しろ、面積めんせきは
1843
  あの人はあの人なりによく考えているらしい。,He appears to think hard in his own way.
1844
  動物は動物なりのコミュニケーションが出来る。,Animals are capable of their own communication.
1845
  小さい大学は小さい大学なりによさがある。,Small colleges have their own merits.
1846
- 私は私なりに、人生観じんせいかんを持っています。,I have my own outlook on life.
1847
  自転車は自転車なりに、車は車なりに、長所ちょうしょ、短所たんしょがある。,A bike and a car have their own merits and demerits.
1848
  健康な人は健康な人なりに、体に気をつけた方がいい。,Healthy people had better take care of themselves in their own way.
1849
  私は老人が老人なりに生活を楽しめる社会が好きだ。,I like a society in which old people can enjoy life in their own way.
 
1843
  あの人はあの人なりによく考えているらしい。,He appears to think hard in his own way.
1844
  動物は動物なりのコミュニケーションが出来る。,Animals are capable of their own communication.
1845
  小さい大学は小さい大学なりによさがある。,Small colleges have their own merits.
1846
+ 私は私なりに、人生観を持っています。,I have my own outlook on life.
1847
  自転車は自転車なりに、車は車なりに、長所ちょうしょ、短所たんしょがある。,A bike and a car have their own merits and demerits.
1848
  健康な人は健康な人なりに、体に気をつけた方がいい。,Healthy people had better take care of themselves in their own way.
1849
  私は老人が老人なりに生活を楽しめる社会が好きだ。,I like a society in which old people can enjoy life in their own way.
app.py CHANGED
@@ -84,31 +84,46 @@ def predict(message, history):
84
 
85
  # Define your initial setup prompt here
86
  initial_setup = f'''
87
-
88
  Japanese students are learning to translate Japanese text to English text. They will be given a Japanese sentence to translate, and will provide an English translation attempt.
89
  Based on the feedback you provide, they will revise their translation. This process will continue until their translation is accurate.
90
 
91
  Encourage the student by specifying the strengths of their writing.
92
- DO NOT PROVIDE THE CORRECT ENGLISH TRANSLATION. Let the student work it out.
93
- The student's translation need not match the provided English translation exactly, but it should be accurate to the Japanese text.
94
- Provide your feedback as a list.
95
 
96
  Execute the following tasks step by step:
97
  1. Ask the student to translate the following sentence from Japanese to English: {japanese_sentence}. Here is the English translation for reference: {english_sentence}
98
  2. Suggest only mechanical corrections (i.e., spelling, grammar, and punctuation) for the student. Ask for another translation attempt.
 
 
99
  '''
 
 
 
 
 
 
100
  # Start your history with a SystemMessage containing the setup prompt
101
  history_langchain_format = [AIMessage(content=initial_setup)]
 
102
 
103
 
104
  for human, ai in history:
105
- history_langchain_format.append(HumanMessage(content=human)) # convert to str to avoid error; not compatible with multimodal
106
- history_langchain_format.append(AIMessage(content=ai))
 
 
107
 
108
  history_langchain_format.append(HumanMessage(content=message))
 
 
109
  gpt_response = llm(history_langchain_format)
110
  return gpt_response.content
111
 
112
- app = gr.ChatInterface(fn=predict, title="Translation Chatbot")#, multimodal=True)
 
 
 
 
113
 
114
  app.launch()
 
84
 
85
  # Define your initial setup prompt here
86
  initial_setup = f'''
 
87
  Japanese students are learning to translate Japanese text to English text. They will be given a Japanese sentence to translate, and will provide an English translation attempt.
88
  Based on the feedback you provide, they will revise their translation. This process will continue until their translation is accurate.
89
 
90
  Encourage the student by specifying the strengths of their writing.
91
+ DO NOT PROVIDE THE CORRECT ENGLISH TRANSLATION until the student gets the correct translation. Let the student work it out.
92
+ Provide your feedback as a list in the format: a, b, c etc.
 
93
 
94
  Execute the following tasks step by step:
95
  1. Ask the student to translate the following sentence from Japanese to English: {japanese_sentence}. Here is the English translation for reference: {english_sentence}
96
  2. Suggest only mechanical corrections (i.e., spelling, grammar, and punctuation) for the student. Ask for another translation attempt.
97
+
98
+ Start by asking the student to translate the Japanese sentence.
99
  '''
100
+
101
+ # removed from prompt
102
+ # The student's translation need not match the provided English translation exactly, but it should be accurate to the Japanese text.
103
+
104
+
105
+
106
  # Start your history with a SystemMessage containing the setup prompt
107
  history_langchain_format = [AIMessage(content=initial_setup)]
108
+ #history_langchain_format.append(HumanMessage(content="Let's start."))
109
 
110
 
111
  for human, ai in history:
112
+ if human is not None:
113
+ history_langchain_format.append(HumanMessage(content=human)) # convert to str to avoid error; not compatible with multimodal
114
+ if ai is not None:
115
+ history_langchain_format.append(AIMessage(content=ai))
116
 
117
  history_langchain_format.append(HumanMessage(content=message))
118
+
119
+ debug_print("### Full history: ", history_langchain_format)
120
  gpt_response = llm(history_langchain_format)
121
  return gpt_response.content
122
 
123
+ welcome_message = "Hi! 👋. Are you ready to practise translation?"
124
+
125
+ app = gr.ChatInterface(fn=predict, title="Translation Chatbot", chatbot=gr.Chatbot(value=[(None, welcome_message)],),)#, multimodal=True) # chatbot=gr.Chatbot(value=[["Welcome 👋. I am an assistant",]])
126
+
127
+
128
 
129
  app.launch()