awacke1 commited on
Commit
cb089bc
β€’
1 Parent(s): 1d3470c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -18
app.py CHANGED
@@ -12,7 +12,6 @@ import json
12
  import uuid # 🎲 For generating unique IDs
13
  from urllib.parse import quote # πŸ”— For encoding URLs
14
  from gradio_client import Client # 🌐 For connecting to Gradio apps
15
- import openai # πŸ€– For OpenAI API interactions
16
  import markdown # πŸ“„ For parsing markdown content
17
  from bs4 import BeautifulSoup # 🍲 For parsing HTML content
18
 
@@ -26,11 +25,9 @@ CONTAINER_NAME = os.environ.get("COSMOS_CONTAINER_NAME")
26
  Key = os.environ.get("Key") # πŸ”‘ Don't forget your key!
27
 
28
  # 🏠 Your local app URL (Change this to your app's URL)
29
- LOCAL_APP_URL = "http://localhost:8501"
 
30
 
31
- # πŸ€– OpenAI configuration
32
- openai.api_key = os.environ.get("OPENAI_API_KEY")
33
- MODEL = "gpt-3.5-turbo" # Replace with your desired model
34
 
35
  # πŸ™ GitHub configuration
36
  def download_github_repo(url, local_path):
@@ -224,21 +221,22 @@ def process_text(text_input, container):
224
  st.markdown(text_input)
225
 
226
  with st.chat_message("assistant"):
227
- completion = openai.ChatCompletion.create(
228
- model=MODEL,
229
- messages=[
230
- {"role": m["role"], "content": m["content"]}
231
- for m in st.session_state.messages
232
- ],
233
- stream=False
234
- )
235
- return_text = completion.choices[0].message.content
236
- st.write("Assistant: " + return_text)
237
- filename = create_and_save_file(return_text, file_type="md", prompt=text_input, is_image=False, should_save=True)
238
- st.session_state.messages.append({"role": "assistant", "content": return_text})
239
 
240
  # Convert markdown to JSON structure
241
- json_content = markdown_to_json(return_text)
 
242
 
243
  # Create a record to insert into Cosmos DB
244
  record = {
 
12
  import uuid # 🎲 For generating unique IDs
13
  from urllib.parse import quote # πŸ”— For encoding URLs
14
  from gradio_client import Client # 🌐 For connecting to Gradio apps
 
15
  import markdown # πŸ“„ For parsing markdown content
16
  from bs4 import BeautifulSoup # 🍲 For parsing HTML content
17
 
 
25
  Key = os.environ.get("Key") # πŸ”‘ Don't forget your key!
26
 
27
  # 🏠 Your local app URL (Change this to your app's URL)
28
+ #LOCAL_APP_URL = "http://localhost:8501"
29
+ LOCAL_APP_URL = "https://huggingface.co/spaces/awacke1/AzureCosmosDBUI"
30
 
 
 
 
31
 
32
  # πŸ™ GitHub configuration
33
  def download_github_repo(url, local_path):
 
221
  st.markdown(text_input)
222
 
223
  with st.chat_message("assistant"):
224
+ # completion = openai.ChatCompletion.create(
225
+ # model=MODEL,
226
+ # messages=[
227
+ # {"role": m["role"], "content": m["content"]}
228
+ # for m in st.session_state.messages
229
+ # ],
230
+ # stream=False
231
+ # )
232
+ # return_text = completion.choices[0].message.content
233
+ # st.write("Assistant: " + return_text)
234
+ # filename = create_and_save_file(return_text, file_type="md", prompt=text_input, is_image=False, should_save=True)
235
+ # st.session_state.messages.append({"role": "assistant", "content": return_text})
236
 
237
  # Convert markdown to JSON structure
238
+ #json_content = markdown_to_json(return_text)
239
+ json_content = markdown_to_json(container)
240
 
241
  # Create a record to insert into Cosmos DB
242
  record = {