Anustup commited on
Commit
a7ba934
·
verified ·
1 Parent(s): 3606f7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -48,7 +48,7 @@ def abstract_assistant(pre_context_to_the_instruction, instruction, name, thread
48
 
49
  return response
50
 
51
- def get_response_for_case_t0(thread_id, query, question_text, input, output, example):
52
 
53
  pre_context_to_the_instruction = f"""```QUESTION:{question_text}```\n```INPUT:{input}```\n```OUTPUT:{output}```\n```EXAMPLE:{example}```"""
54
  instruction = f"""Act as a Coding Mentor for a student who is currently learning Data Structures and algorithms(DSA). The student is asking a QUERY: {query} based on the
@@ -64,7 +64,7 @@ def get_response_for_case_t0(thread_id, query, question_text, input, output, exa
64
  return response
65
 
66
 
67
- def opening_statement(thread_id, question_text, input, output, example):
68
  pre_context_to_the_instruction = f"""```QUESTION:{question_text}```\n```INPUT:{input}```\n```OUTPUT:{output}```\n```EXAMPLE:{example}```"""
69
  instruction = f"""Act as a Coding Mentor for a student who is currently learning Data Structures and algorithms(DSA). Now the student
70
  is stuck in the question for long amount of time so Ask him in a gentle motivational tone to tell or to start think where
@@ -77,7 +77,7 @@ def opening_statement(thread_id, question_text, input, output, example):
77
  return response
78
 
79
 
80
- def response_evaluation_for_case_tx(thread_id, query, question_text, input, output, example, user_code):
81
  pre_context_to_the_instruction = f"""```QUESTION:{question_text}```\n```INPUT:{input}```\n```OUTPUT:{output}```\n```EXAMPLE:{example}```"""
82
  instruction = f"""Act as a Coding Mentor for a student who is currently learning Data Structures and algorithms(DSA). The student is asking a QUERY: {query} based on the
83
  coding question : QUESTION which have input : INPUT output: OUTPUT and examples: EXAMPLE. Now follow the following instrutions:
@@ -102,11 +102,11 @@ def run_chat_in_all_cases(message, history, question_text,input, output, example
102
  thread = client.beta.threads.create()
103
  thread_id = thread.id
104
  if not message and not code_written:
105
- ai_message = opening_statement(thread_id, question_text, input, output, examples)
106
  if not code_written:
107
- ai_message = get_response_for_case_t0(thread_id, message, question_text, input, output, examples)
108
  else:
109
- ai_message = response_evaluation_for_case_tx(thread_id, message, question_text, input, output, examples, code_written)
110
  print({"question_text":question_text, "input":input, "output":output, "examples":examples,
111
  "user_code":code_written, "query":message, "ai_message":ai_message})
112
  return ai_message
 
48
 
49
  return response
50
 
51
+ def get_response_for_case_t0(thread_id, query, question_text, input, output, example, thread):
52
 
53
  pre_context_to_the_instruction = f"""```QUESTION:{question_text}```\n```INPUT:{input}```\n```OUTPUT:{output}```\n```EXAMPLE:{example}```"""
54
  instruction = f"""Act as a Coding Mentor for a student who is currently learning Data Structures and algorithms(DSA). The student is asking a QUERY: {query} based on the
 
64
  return response
65
 
66
 
67
+ def opening_statement(thread_id, question_text, input, output, example, thread):
68
  pre_context_to_the_instruction = f"""```QUESTION:{question_text}```\n```INPUT:{input}```\n```OUTPUT:{output}```\n```EXAMPLE:{example}```"""
69
  instruction = f"""Act as a Coding Mentor for a student who is currently learning Data Structures and algorithms(DSA). Now the student
70
  is stuck in the question for long amount of time so Ask him in a gentle motivational tone to tell or to start think where
 
77
  return response
78
 
79
 
80
+ def response_evaluation_for_case_tx(thread_id, query, question_text, input, output, example, user_code, thread):
81
  pre_context_to_the_instruction = f"""```QUESTION:{question_text}```\n```INPUT:{input}```\n```OUTPUT:{output}```\n```EXAMPLE:{example}```"""
82
  instruction = f"""Act as a Coding Mentor for a student who is currently learning Data Structures and algorithms(DSA). The student is asking a QUERY: {query} based on the
83
  coding question : QUESTION which have input : INPUT output: OUTPUT and examples: EXAMPLE. Now follow the following instrutions:
 
102
  thread = client.beta.threads.create()
103
  thread_id = thread.id
104
  if not message and not code_written:
105
+ ai_message = opening_statement(thread_id, question_text, input, output, examples, thread)
106
  if not code_written:
107
+ ai_message = get_response_for_case_t0(thread_id, message, question_text, input, output, examples, thread)
108
  else:
109
+ ai_message = response_evaluation_for_case_tx(thread_id, message, question_text, input, output, examples, code_written, thread)
110
  print({"question_text":question_text, "input":input, "output":output, "examples":examples,
111
  "user_code":code_written, "query":message, "ai_message":ai_message})
112
  return ai_message