-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackend.py
More file actions
46 lines (39 loc) · 1.39 KB
/
Copy pathbackend.py
File metadata and controls
46 lines (39 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from mira_sdk import MiraClient, Flow
import os
from dotenv import load_dotenv
# Load API key from environment variables
def give_response(prompt):
load_dotenv()
YOUR_API_KEY = os.getenv("OPENROUTER_API_KEY")
# Initialize the client
client = MiraClient(config={"API_KEY": YOUR_API_KEY})
prompt = prompt+ " Also recommend leetcode or codeforces questions with link if necessary."
version = "1.0.0"
input_data = {
"prompt": prompt
}
# If no version is provided, latest version is used by default
if version:
flow_name = f"@sparsh-r/coding-assistant/{version}"
else:
flow_name = "@sparsh-r/coding-assistant"
result = client.flow.execute(flow_name, input_data)
return result["result"]
def give_tags(prompt):
from mira_sdk import MiraClient, Flow
load_dotenv()
YOUR_API_KEY = os.getenv("OPENROUTER_API_KEY")
# Initialize the client
client = MiraClient(config={"API_KEY": YOUR_API_KEY})
version = "1.0.0"
input_data = {
"prompt": prompt
}
# If no version is provided, latest version is used by default
if version:
flow_name = f"@sparsh-r/tag-generator/{version}"
else:
flow_name = "@sparsh-r/tag-generator"
result = client.flow.execute(flow_name, input_data)
return result["result"].replace("'","`")
#print(give_response("recommend leetcode questions"))