Spaces:
Runtime error
Runtime error
Commit
·
a875418
1
Parent(s):
88bd7aa
Update app.py
Browse files
app.py
CHANGED
@@ -1,43 +1,40 @@
|
|
1 |
import os
|
2 |
-
import
|
3 |
-
import
|
4 |
-
import
|
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 |
-
title="Create a Conversational AI Chatbot for Your Public GitHub Repository Codebase",
|
42 |
-
theme="huggingface_dark",
|
43 |
-
).launch()
|
|
|
1 |
import os
|
2 |
+
import streamlit as st
|
3 |
+
from langchain import HuggingFaceHub, LLMChain
|
4 |
+
from git import Repo
|
5 |
+
|
6 |
+
# Run pip freeze and pip install -r requirements.txt
|
7 |
+
os.system("pip freeze > requirements.txt")
|
8 |
+
os.system("pip install -r requirements.txt")
|
9 |
+
|
10 |
+
st.set_page_config(layout="wide", initial_sidebar_state="auto", theme="dark")
|
11 |
+
st.title("Hugging Face Space Demo")
|
12 |
+
|
13 |
+
repository_url = st.text_input("Enter GitHub repository URL:", "")
|
14 |
+
access_token = st.text_input("Enter GitHub access token (optional):", "")
|
15 |
+
debug_logging = st.checkbox("Enable debug logging")
|
16 |
+
|
17 |
+
if st.button("Run"):
|
18 |
+
if debug_logging:
|
19 |
+
import logging
|
20 |
+
logging.basicConfig(filename='log.txt', level=logging.DEBUG, format='%(asctime)s %(message)s')
|
21 |
+
logging.debug('Starting the process')
|
22 |
+
|
23 |
+
# Clone the repository
|
24 |
+
local_path = "/tmp/repository"
|
25 |
+
Repo.clone_from(repository_url, local_path, branch="main", env={"GIT_TERMINAL_PROMPT": "0", "GIT_SSL_NO_VERIFY": "true"})
|
26 |
+
|
27 |
+
# Initialize Hugging Face model
|
28 |
+
os.environ['HUGGINGFACEHUB_API_TOKEN'] = access_token
|
29 |
+
hub_llm = HuggingFaceHub(repo_id='google/flan-t5-xl', model_kwargs={'temperature': 1e-10})
|
30 |
+
|
31 |
+
# Create a prompt template and LLM chain
|
32 |
+
prompt = "What is the main purpose of the repository at {}?".format(repository_url)
|
33 |
+
llm_chain = LLMChain(prompt=prompt, llm=hub_llm)
|
34 |
+
|
35 |
+
# Get the result
|
36 |
+
answer = llm_chain.run()
|
37 |
+
st.write("Answer:", answer)
|
38 |
+
|
39 |
+
if debug_logging:
|
40 |
+
logging.debug('Finished the process')
|
|
|
|
|
|