Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -29,7 +29,7 @@ def download_model():
|
|
29 |
def start_tunnel():
|
30 |
# Start nport tunnel
|
31 |
tunnel_process = subprocess.Popen(
|
32 |
-
["npx", "nport", "-s", "ai-service
|
33 |
stdout=subprocess.PIPE,
|
34 |
stderr=subprocess.PIPE,
|
35 |
)
|
@@ -57,6 +57,11 @@ def push_tunnel_url_to_repo(tunnel_url):
|
|
57 |
# Clone the repository
|
58 |
repo_dir = "/tmp/repo"
|
59 |
repo_url = f"https://x-access-token:{GH_PAT}@github.com/NitinBot001/Audio-url-new-js.git"
|
|
|
|
|
|
|
|
|
|
|
60 |
subprocess.run(
|
61 |
["git", "clone", repo_url, repo_dir],
|
62 |
check=True,
|
@@ -70,19 +75,27 @@ def push_tunnel_url_to_repo(tunnel_url):
|
|
70 |
subprocess.run(["git", "config", "user.email", "[email protected]"], check=True)
|
71 |
subprocess.run(["git", "config", "user.name", "github-actions"], check=True)
|
72 |
|
73 |
-
#
|
74 |
subprocess.run(["git", "add", "instance.json"], check=True)
|
75 |
-
subprocess.run(["git", "commit", "-m", f"Update tunnel URL to {tunnel_url}"], check=True)
|
76 |
-
subprocess.run(["git", "push", "origin", "main"], check=True)
|
77 |
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
def chat():
|
80 |
-
|
|
|
|
|
81 |
# Construct the prompt without duplicate special tokens
|
82 |
prompt = (
|
83 |
f"<|begin_of_text|>"
|
84 |
f"<|start_header_id|>user<|end_header_id|>\n"
|
85 |
-
f"{
|
86 |
f"<|eot_id|>\n"
|
87 |
f"<|start_header_id|>assistant<|end_header_id|>\n"
|
88 |
)
|
|
|
29 |
def start_tunnel():
|
30 |
# Start nport tunnel
|
31 |
tunnel_process = subprocess.Popen(
|
32 |
+
["npx", "nport", "-s", "ai-service", "-p", "5000"],
|
33 |
stdout=subprocess.PIPE,
|
34 |
stderr=subprocess.PIPE,
|
35 |
)
|
|
|
57 |
# Clone the repository
|
58 |
repo_dir = "/tmp/repo"
|
59 |
repo_url = f"https://x-access-token:{GH_PAT}@github.com/NitinBot001/Audio-url-new-js.git"
|
60 |
+
|
61 |
+
# Remove the existing repo directory if it exists
|
62 |
+
if os.path.exists(repo_dir):
|
63 |
+
subprocess.run(["rm", "-rf", repo_dir], check=True)
|
64 |
+
|
65 |
subprocess.run(
|
66 |
["git", "clone", repo_url, repo_dir],
|
67 |
check=True,
|
|
|
75 |
subprocess.run(["git", "config", "user.email", "[email protected]"], check=True)
|
76 |
subprocess.run(["git", "config", "user.name", "github-actions"], check=True)
|
77 |
|
78 |
+
# Add the file to the staging area
|
79 |
subprocess.run(["git", "add", "instance.json"], check=True)
|
|
|
|
|
80 |
|
81 |
+
# Check if there are changes to commit
|
82 |
+
result = subprocess.run(["git", "status", "--porcelain"], stdout=subprocess.PIPE, text=True)
|
83 |
+
if result.stdout.strip(): # If there are changes
|
84 |
+
subprocess.run(["git", "commit", "-m", f"Update tunnel URL to {tunnel_url}"], check=True)
|
85 |
+
subprocess.run(["git", "push", "origin", "main"], check=True)
|
86 |
+
else:
|
87 |
+
print("No changes to commit.")
|
88 |
+
|
89 |
+
@app.route("/chat", methods=["GET"])
|
90 |
def chat():
|
91 |
+
# Get the message from the query parameter
|
92 |
+
message = request.args.get("message", "")
|
93 |
+
|
94 |
# Construct the prompt without duplicate special tokens
|
95 |
prompt = (
|
96 |
f"<|begin_of_text|>"
|
97 |
f"<|start_header_id|>user<|end_header_id|>\n"
|
98 |
+
f"{message}"
|
99 |
f"<|eot_id|>\n"
|
100 |
f"<|start_header_id|>assistant<|end_header_id|>\n"
|
101 |
)
|