eagle0504 commited on
Commit
86e49cc
·
verified ·
1 Parent(s): b35b8c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -43
app.py CHANGED
@@ -1,47 +1,5 @@
1
  import streamlit as st
2
- import requests
3
- import json
4
-
5
- # API Gateway Invoke URL (Replace with your actual API endpoint)
6
- API_URL = "https://zyqnod20re.execute-api.us-east-1.amazonaws.com/dev/test_bedrock_v4_deepseek"
7
-
8
- # Function to call DeepSeek-R1 model
9
- def query_deepseek(prompt: str, max_gen_len: int, temperature: float, top_p: float) -> str:
10
- """
11
- Sends a request to the DeepSeek-R1 model via AWS Bedrock API and returns the response.
12
-
13
- Args:
14
- prompt (str): The user input query.
15
- max_gen_len (int): The maximum length of the generated response.
16
- temperature (float): Controls the randomness of the model output.
17
- top_p (float): The nucleus sampling parameter.
18
-
19
- Returns:
20
- str: The generated response from the model.
21
- """
22
- payload = {
23
- "prompt": prompt,
24
- "max_gen_len": max_gen_len,
25
- "temperature": temperature,
26
- "top_p": top_p
27
- }
28
-
29
- headers = {"Content-Type": "application/json"}
30
-
31
- try:
32
- response = requests.post(API_URL, headers=headers, data=json.dumps(payload))
33
-
34
- if response.status_code == 200:
35
- full_response = response.json()
36
-
37
- # Extract the output text from the model response
38
- output_text = full_response.get("model_response", {}).get("generation", "No output found.")
39
- return output_text
40
- else:
41
- return f"Error {response.status_code}: {response.text}"
42
-
43
- except requests.exceptions.RequestException as e:
44
- return f"Request failed: {e}"
45
 
46
  # Streamlit app UI
47
  st.title("🤖 DeepSeek-R1 Chatbot")
 
1
  import streamlit as st
2
+ from helper import query_deepseek # Import the backend function
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  # Streamlit app UI
5
  st.title("🤖 DeepSeek-R1 Chatbot")