Matthew Lee commited on
Commit
5e1fc5e
·
1 Parent(s): caac916
Files changed (6) hide show
  1. .python-version +1 -0
  2. README.md +1 -1
  3. app.py +11 -12
  4. hello.py +6 -0
  5. pyproject.toml +12 -0
  6. uv.lock +0 -0
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.13
README.md CHANGED
@@ -9,4 +9,4 @@ app_file: app.py
9
  pinned: false
10
  ---
11
 
12
- An example chatbot using [Gradio](https://gradio.app), [`huggingface_hub`](https://huggingface.co/docs/huggingface_hub/v0.22.2/en/index), and the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).
 
9
  pinned: false
10
  ---
11
 
12
+ An demo chatbot for Stanford's CS 234 final project.
app.py CHANGED
@@ -1,10 +1,11 @@
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(
@@ -25,19 +26,17 @@ def respond(
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
  """
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
  """
5
+ For more information on `transformers` library, please check the docs: https://huggingface.co/docs/transformers/
6
  """
7
+ model_name = "BabyChou/Deepseek-R1-Distill-Qwen-1.5B-GSM8K-GRPO-beta-0.001"
8
+ chatbot = pipeline("text-generation", model=model_name)
9
 
10
 
11
  def respond(
 
26
 
27
  messages.append({"role": "user", "content": message})
28
 
29
+ input_text = "\n".join([msg["content"] for msg in messages])
30
 
31
+ response = chatbot(
32
+ input_text,
33
+ max_length=max_tokens,
34
+ do_sample=True,
35
  temperature=temperature,
36
  top_p=top_p,
37
+ )[0]["generated_text"]
 
38
 
39
+ yield response
 
40
 
41
 
42
  """
hello.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ def main():
2
+ print("Hello from concise-cognition-demo!")
3
+
4
+
5
+ if __name__ == "__main__":
6
+ main()
pyproject.toml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "concise-cognition-demo"
3
+ version = "0.1.0"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ requires-python = ">=3.13"
7
+ dependencies = [
8
+ "gradio>=5.20.1",
9
+ "huggingface-hub>=0.29.3",
10
+ "torch>=2.6.0",
11
+ "transformers>=4.49.0",
12
+ ]
uv.lock ADDED
The diff for this file is too large to render. See raw diff