Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,10 +3,10 @@ from openai import OpenAI
|
|
3 |
|
4 |
def process_language(api_key, task, user_message):
|
5 |
if not api_key:
|
6 |
-
return "β οΈ Please enter your
|
7 |
|
8 |
client = OpenAI(
|
9 |
-
base_url="https://
|
10 |
api_key=api_key
|
11 |
)
|
12 |
|
@@ -16,9 +16,7 @@ def process_language(api_key, task, user_message):
|
|
16 |
|
17 |
try:
|
18 |
completion = client.chat.completions.create(
|
19 |
-
|
20 |
-
extra_body={},
|
21 |
-
model="deepseek/deepseek-v3-base:free",
|
22 |
messages=[
|
23 |
{"role": "system", "content": system_message},
|
24 |
{"role": "user", "content": f"{task}: {user_message}"}
|
@@ -30,10 +28,10 @@ def process_language(api_key, task, user_message):
|
|
30 |
|
31 |
def process_pseudocode(api_key, user_idea):
|
32 |
if not api_key:
|
33 |
-
return "β οΈ Please enter your
|
34 |
|
35 |
client = OpenAI(
|
36 |
-
base_url="https://
|
37 |
api_key=api_key
|
38 |
)
|
39 |
|
@@ -42,9 +40,7 @@ def process_pseudocode(api_key, user_idea):
|
|
42 |
|
43 |
try:
|
44 |
completion = client.chat.completions.create(
|
45 |
-
|
46 |
-
extra_body={},
|
47 |
-
model="deepseek/deepseek-v3-base:free",
|
48 |
messages=[
|
49 |
{"role": "system", "content": system_message},
|
50 |
{"role": "user", "content": user_idea}
|
@@ -56,10 +52,10 @@ def process_pseudocode(api_key, user_idea):
|
|
56 |
|
57 |
def process_algorithm(api_key, challenge):
|
58 |
if not api_key:
|
59 |
-
return "β οΈ Please enter your
|
60 |
|
61 |
client = OpenAI(
|
62 |
-
base_url="https://
|
63 |
api_key=api_key
|
64 |
)
|
65 |
|
@@ -68,9 +64,7 @@ def process_algorithm(api_key, challenge):
|
|
68 |
|
69 |
try:
|
70 |
completion = client.chat.completions.create(
|
71 |
-
|
72 |
-
extra_body={},
|
73 |
-
model="deepseek/deepseek-v3-base:free",
|
74 |
messages=[
|
75 |
{"role": "system", "content": system_message},
|
76 |
{"role": "user", "content": challenge}
|
@@ -81,11 +75,10 @@ def process_algorithm(api_key, challenge):
|
|
81 |
return f"β Error: {str(e)}"
|
82 |
|
83 |
with gr.Blocks(theme=gr.themes.Soft()) as app:
|
84 |
-
gr.Markdown("# π Code & Language Learning Assistant")
|
85 |
-
api_key = gr.Textbox(label="Enter your
|
86 |
|
87 |
with gr.Tabs():
|
88 |
-
# Language Learning Tab
|
89 |
with gr.Tab("π¬π§/π¨π³ Language Learning Buddy"):
|
90 |
with gr.Row():
|
91 |
with gr.Column():
|
@@ -98,7 +91,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
|
|
98 |
lang_output = gr.Textbox(label="Assistant Response", interactive=False, lines=10)
|
99 |
lang_btn.click(process_language, [api_key, task_type, lang_input], lang_output)
|
100 |
|
101 |
-
# Pseudocode Tab
|
102 |
with gr.Tab("π Pseudocode Explainer"):
|
103 |
with gr.Row():
|
104 |
with gr.Column():
|
@@ -107,7 +99,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
|
|
107 |
pseudo_output = gr.Textbox(label="Step-by-Step Pseudocode", interactive=False, lines=10)
|
108 |
pseudo_btn.click(process_pseudocode, [api_key, pseudo_input], pseudo_output)
|
109 |
|
110 |
-
# Algorithm Tab
|
111 |
with gr.Tab("π§ Algorithm Brainstormer"):
|
112 |
with gr.Row():
|
113 |
with gr.Column():
|
|
|
3 |
|
4 |
def process_language(api_key, task, user_message):
|
5 |
if not api_key:
|
6 |
+
return "β οΈ Please enter your Groq API Key"
|
7 |
|
8 |
client = OpenAI(
|
9 |
+
base_url="https://api.groq.com/openai/v1",
|
10 |
api_key=api_key
|
11 |
)
|
12 |
|
|
|
16 |
|
17 |
try:
|
18 |
completion = client.chat.completions.create(
|
19 |
+
model="mixtral-8x7b-32768",
|
|
|
|
|
20 |
messages=[
|
21 |
{"role": "system", "content": system_message},
|
22 |
{"role": "user", "content": f"{task}: {user_message}"}
|
|
|
28 |
|
29 |
def process_pseudocode(api_key, user_idea):
|
30 |
if not api_key:
|
31 |
+
return "β οΈ Please enter your Groq API Key"
|
32 |
|
33 |
client = OpenAI(
|
34 |
+
base_url="https://api.groq.com/openai/v1",
|
35 |
api_key=api_key
|
36 |
)
|
37 |
|
|
|
40 |
|
41 |
try:
|
42 |
completion = client.chat.completions.create(
|
43 |
+
model="llama2-70b-4096",
|
|
|
|
|
44 |
messages=[
|
45 |
{"role": "system", "content": system_message},
|
46 |
{"role": "user", "content": user_idea}
|
|
|
52 |
|
53 |
def process_algorithm(api_key, challenge):
|
54 |
if not api_key:
|
55 |
+
return "β οΈ Please enter your Groq API Key"
|
56 |
|
57 |
client = OpenAI(
|
58 |
+
base_url="https://api.groq.com/openai/v1",
|
59 |
api_key=api_key
|
60 |
)
|
61 |
|
|
|
64 |
|
65 |
try:
|
66 |
completion = client.chat.completions.create(
|
67 |
+
model="mixtral-8x7b-32768",
|
|
|
|
|
68 |
messages=[
|
69 |
{"role": "system", "content": system_message},
|
70 |
{"role": "user", "content": challenge}
|
|
|
75 |
return f"β Error: {str(e)}"
|
76 |
|
77 |
with gr.Blocks(theme=gr.themes.Soft()) as app:
|
78 |
+
gr.Markdown("# π Code & Language Learning Assistant (Groq Version)")
|
79 |
+
api_key = gr.Textbox(label="Enter your Groq API Key", type="password")
|
80 |
|
81 |
with gr.Tabs():
|
|
|
82 |
with gr.Tab("π¬π§/π¨π³ Language Learning Buddy"):
|
83 |
with gr.Row():
|
84 |
with gr.Column():
|
|
|
91 |
lang_output = gr.Textbox(label="Assistant Response", interactive=False, lines=10)
|
92 |
lang_btn.click(process_language, [api_key, task_type, lang_input], lang_output)
|
93 |
|
|
|
94 |
with gr.Tab("π Pseudocode Explainer"):
|
95 |
with gr.Row():
|
96 |
with gr.Column():
|
|
|
99 |
pseudo_output = gr.Textbox(label="Step-by-Step Pseudocode", interactive=False, lines=10)
|
100 |
pseudo_btn.click(process_pseudocode, [api_key, pseudo_input], pseudo_output)
|
101 |
|
|
|
102 |
with gr.Tab("π§ Algorithm Brainstormer"):
|
103 |
with gr.Row():
|
104 |
with gr.Column():
|