david4096 commited on
Commit
bb76ad8
1 Parent(s): 86a29de
Files changed (3) hide show
  1. .gitattributes +1 -0
  2. app.py +35 -55
  3. huggingface.ttl +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.ttl filter=lfs diff=lfs merge=lfs -text
app.py CHANGED
@@ -1,63 +1,43 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
 
3
 
4
- """
5
- For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
- """
7
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
-
9
-
10
- def respond(
11
- message,
12
- history: list[tuple[str, str]],
13
- system_message,
14
- max_tokens,
15
- temperature,
16
- top_p,
17
- ):
18
- messages = [{"role": "system", "content": system_message}]
19
-
20
- for val in history:
21
- if val[0]:
22
- messages.append({"role": "user", "content": val[0]})
23
- if val[1]:
24
- messages.append({"role": "assistant", "content": val[1]})
25
-
26
- messages.append({"role": "user", "content": message})
27
-
28
- response = ""
29
-
30
- for message in client.chat_completion(
31
- messages,
32
- max_tokens=max_tokens,
33
- stream=True,
34
- temperature=temperature,
35
- top_p=top_p,
36
- ):
37
- token = message.choices[0].delta.content
38
-
39
- response += token
40
- yield response
41
 
 
 
42
 
43
- """
44
- For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
45
- """
46
- demo = gr.ChatInterface(
47
- respond,
48
- additional_inputs=[
49
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
50
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
51
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
52
- gr.Slider(
53
- minimum=0.1,
54
- maximum=1.0,
55
- value=0.95,
56
- step=0.05,
57
- label="Top-p (nucleus sampling)",
58
- ),
59
- ],
60
- )
61
 
62
 
63
  if __name__ == "__main__":
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
+ import rdflib
4
 
5
+ import gradio as gr
6
+ import rdflib
7
+
8
+ # Load the Turtle file and initialize the graph
9
+ g = rdflib.Graph()
10
+ g.parse('huggingface.ttl')
11
+
12
+ # Define the function to execute the SPARQL query
13
+ def run_sparql(query):
14
+ try:
15
+ qres = g.query(query)
16
+ results = []
17
+ for row in qres:
18
+ # Concatenate each row's results into a readable string
19
+ result = " | ".join(str(cell) for cell in row)
20
+ results.append(result)
21
+ return "\n".join(results) if results else "No results found."
22
+ except Exception as e:
23
+ return f"Error: {e}"
24
+
25
+ # Gradio interface
26
+ query_input = gr.Textbox(label="SPARQL Query", lines=5, placeholder="Enter your SPARQL query here")
27
+ output_text = gr.Textbox(label="Query Results", lines=10)
28
+
29
+ # Launch the app
30
+ demo = gr.Interface(
31
+ fn=run_sparql,
32
+ inputs=query_input,
33
+ outputs=output_text,
34
+ title="SPARQL Query Interface",
35
+ description="Enter a SPARQL query to retrieve data from the Turtle file.",
36
+ )
 
 
 
 
 
37
 
38
+ if __name__ == "__main__":
39
+ demo.launch()
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
 
43
  if __name__ == "__main__":
huggingface.ttl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b427f632d71c69ffc8a820689d3ffc0ecd764aa9af7920b57c69afb3c366655f
3
+ size 22698390