wxgeorge commited on
Commit
6f983da
1 Parent(s): 2433428

:fire: revert manual chat templating for reflection now that it's working in featherless backend.

Browse files

This reverts commit ae83cd880af013682c84eb953bb9954683ae5607.

Files changed (2) hide show
  1. app.py +16 -50
  2. requirements.txt +1 -205
app.py CHANGED
@@ -2,12 +2,6 @@ from openai import OpenAI
2
  import gradio as gr
3
  import os
4
  import json
5
- import functools
6
- import random
7
- import datetime
8
- from transformers import AutoTokenizer
9
-
10
- reflection_tokenizer = AutoTokenizer.from_pretrained("mattshumer/Reflection-Llama-3.1-70B")
11
 
12
  api_key = os.environ.get('FEATHERLESS_API_KEY')
13
  client = OpenAI(
@@ -24,51 +18,23 @@ def respond(message, history, model):
24
  history_openai_format.append({"role": "assistant", "content":assistant})
25
  history_openai_format.append({"role": "user", "content": message})
26
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
- if model == "mattshumer/Reflection-Llama-3.1-70B":
29
- # chat/completions not working for this model;
30
- # apply chat template locally
31
- response = client.completions.create(
32
- model=model,
33
- prompt=reflection_tokenizer.apply_chat_template(history_openai_format, tokenize=False),
34
- temperature=1.0,
35
- stream=True,
36
- max_tokens=2000,
37
- extra_headers={
38
- 'HTTP-Referer': 'https://huggingface.co/spaces/featherless-ai/try-this-model',
39
- 'X-Title': "HF's missing inference widget"
40
- }
41
- )
42
-
43
- # debugger_ran = False
44
- partial_message = ""
45
- for chunk in response:
46
- # if not debugger_ran:
47
- # import code
48
- # code.InteractiveConsole(locals=locals()).interact()
49
- # debugger_ran = True
50
- if chunk.choices[0].text is not None:
51
- partial_message = partial_message + chunk.choices[0].text
52
- prefix_to_strip = "<|start_header_id|>assistant<|end_header_id|>\n\n"
53
- yield partial_message[len(prefix_to_strip):]
54
- else:
55
- response = client.chat.completions.create(
56
- model=model,
57
- messages= history_openai_format,
58
- temperature=1.0,
59
- stream=True,
60
- max_tokens=2000,
61
- extra_headers={
62
- 'HTTP-Referer': 'https://huggingface.co/spaces/featherless-ai/try-this-model',
63
- 'X-Title': "HF's missing inference widget"
64
- }
65
- )
66
-
67
- partial_message = ""
68
- for chunk in response:
69
- if chunk.choices[0].delta.content is not None:
70
- partial_message = partial_message + chunk.choices[0].delta.content
71
- yield partial_message
72
 
73
  logo = open('./logo.svg').read()
74
 
 
2
  import gradio as gr
3
  import os
4
  import json
 
 
 
 
 
 
5
 
6
  api_key = os.environ.get('FEATHERLESS_API_KEY')
7
  client = OpenAI(
 
18
  history_openai_format.append({"role": "assistant", "content":assistant})
19
  history_openai_format.append({"role": "user", "content": message})
20
 
21
+ response = client.chat.completions.create(
22
+ model=model,
23
+ messages= history_openai_format,
24
+ temperature=1.0,
25
+ stream=True,
26
+ max_tokens=2000,
27
+ extra_headers={
28
+ 'HTTP-Referer': 'https://huggingface.co/spaces/featherless-ai/try-this-model',
29
+ 'X-Title': "HF's missing inference widget"
30
+ }
31
+ )
32
 
33
+ partial_message = ""
34
+ for chunk in response:
35
+ if chunk.choices[0].delta.content is not None:
36
+ partial_message = partial_message + chunk.choices[0].delta.content
37
+ yield partial_message
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  logo = open('./logo.svg').read()
40
 
requirements.txt CHANGED
@@ -1,205 +1 @@
1
- accelerate==0.32.1
2
- aiofiles==23.2.1
3
- aiohttp==3.9.5
4
- aiosignal==1.3.1
5
- altair==5.3.0
6
- annotated-types==0.7.0
7
- anyio==4.4.0
8
- appnope==0.1.4
9
- argon2-cffi==23.1.0
10
- argon2-cffi-bindings==21.2.0
11
- arrow==1.3.0
12
- asttokens==2.4.1
13
- async-lru==2.0.4
14
- attrs==23.2.0
15
- Babel==2.15.0
16
- beautifulsoup4==4.12.3
17
- bleach==6.1.0
18
- certifi==2024.6.2
19
- cffi==1.16.0
20
- charset-normalizer==3.3.2
21
- click==8.1.7
22
- click-default-group==1.2.4
23
- comm==0.2.2
24
- contourpy==1.2.1
25
- cycler==0.12.1
26
- dataclasses-json==0.6.7
27
- debugpy==1.8.2
28
- decorator==5.1.1
29
- defusedxml==0.7.1
30
- distro==1.9.0
31
- dnspython==2.6.1
32
- email_validator==2.2.0
33
- executing==2.0.1
34
- fastapi==0.111.0
35
- fastapi-cli==0.0.4
36
- fastjsonschema==2.20.0
37
- ffmpy==0.3.2
38
- filelock==3.15.4
39
- fonttools==4.53.1
40
- fqdn==1.5.1
41
- frozenlist==1.4.1
42
- fschat==0.2.36
43
- fsspec==2024.6.1
44
- gradio==4.37.2
45
- gradio_client==1.0.2
46
- greenlet==3.0.3
47
- h11==0.14.0
48
- httpcore==1.0.5
49
- httptools==0.6.1
50
- httpx==0.27.0
51
- huggingface-hub==0.23.4
52
- idna==3.7
53
- importlib_resources==6.4.0
54
- ipykernel==6.29.5
55
- ipython==8.26.0
56
- ipywidgets==8.1.3
57
- isoduration==20.11.0
58
- jedi==0.19.1
59
- Jinja2==3.1.4
60
- json5==0.9.25
61
- jsonpatch==1.33
62
- jsonpointer==3.0.0
63
- jsonschema==4.22.0
64
- jsonschema-specifications==2023.12.1
65
- jupyter==1.0.0
66
- jupyter-console==6.6.3
67
- jupyter-events==0.10.0
68
- jupyter-lsp==2.2.5
69
- jupyter_client==8.6.2
70
- jupyter_core==5.7.2
71
- jupyter_server==2.14.1
72
- jupyter_server_terminals==0.5.3
73
- jupyterlab==4.2.3
74
- jupyterlab_pygments==0.3.0
75
- jupyterlab_server==2.27.2
76
- jupyterlab_widgets==3.0.11
77
- kiwisolver==1.4.5
78
- langchain==0.2.5
79
- langchain-community==0.2.5
80
- langchain-core==0.2.9
81
- langchain-openai==0.1.8
82
- langchain-text-splitters==0.2.1
83
- langsmith==0.1.81
84
- latex2mathml==3.77.0
85
- llm==0.14
86
- llm-openrouter==0.2
87
- markdown-it-py==3.0.0
88
- markdown2==2.5.0
89
- MarkupSafe==2.1.5
90
- marshmallow==3.21.3
91
- matplotlib==3.9.1
92
- matplotlib-inline==0.1.7
93
- mdurl==0.1.2
94
- mistune==3.0.2
95
- mpmath==1.3.0
96
- multidict==6.0.5
97
- mypy-extensions==1.0.0
98
- nbclient==0.10.0
99
- nbconvert==7.16.4
100
- nbformat==5.10.4
101
- nest-asyncio==1.6.0
102
- networkx==3.3
103
- nh3==0.2.18
104
- notebook==7.2.1
105
- notebook_shim==0.2.4
106
- numpy==1.26.4
107
- openai==1.35.2
108
- orjson==3.10.5
109
- overrides==7.7.0
110
- packaging==24.1
111
- pandas==2.2.2
112
- pandocfilters==1.5.1
113
- parso==0.8.4
114
- peft==0.11.1
115
- pexpect==4.9.0
116
- pillow==10.4.0
117
- platformdirs==4.2.2
118
- plotly==5.22.0
119
- pluggy==1.5.0
120
- prometheus_client==0.20.0
121
- prompt_toolkit==3.0.47
122
- protobuf==5.27.2
123
- psutil==6.0.0
124
- psycopg==3.2.1
125
- ptyprocess==0.7.0
126
- pure-eval==0.2.2
127
- pycparser==2.22
128
- pydantic==2.7.4
129
- pydantic-settings==2.3.4
130
- pydantic_core==2.18.4
131
- pydub==0.25.1
132
- Pygments==2.18.0
133
- pymongo==4.8.0
134
- pyparsing==3.1.2
135
- python-dateutil==2.9.0.post0
136
- python-dotenv==1.0.1
137
- python-json-logger==2.0.7
138
- python-multipart==0.0.9
139
- python-ulid==2.7.0
140
- pytz==2024.1
141
- PyYAML==6.0.1
142
- pyzmq==26.0.3
143
- qtconsole==5.5.2
144
- QtPy==2.4.1
145
- referencing==0.35.1
146
- regex==2024.5.15
147
- requests==2.32.3
148
- rfc3339-validator==0.1.4
149
- rfc3986-validator==0.1.1
150
- rich==13.7.1
151
- rpds-py==0.18.1
152
- ruff==0.5.1
153
- safetensors==0.4.3
154
- semantic-version==2.10.0
155
- Send2Trash==1.8.3
156
- sentencepiece==0.2.0
157
- setuptools==70.1.1
158
- shellingham==1.5.4
159
- shortuuid==1.0.13
160
- six==1.16.0
161
- sniffio==1.3.1
162
- soupsieve==2.5
163
- SQLAlchemy==2.0.31
164
- sqlite-fts4==1.0.3
165
- sqlite-migrate==0.1b0
166
- sqlite-utils==3.36
167
- sseclient==0.0.27
168
- sseclient-py==1.8.0
169
- stack-data==0.6.3
170
- starlette==0.37.2
171
- stripe==10.8.0
172
- svgwrite==1.4.3
173
- sympy==1.13.0
174
- tabulate==0.9.0
175
- tenacity==8.4.1
176
- terminado==0.18.1
177
- tiktoken==0.7.0
178
- tinycss2==1.3.0
179
- tokenizers==0.19.1
180
- tomlkit==0.12.0
181
- toolz==0.12.1
182
- torch==2.2.2
183
- tornado==6.4.1
184
- tqdm==4.66.4
185
- traitlets==5.14.3
186
- transformers==4.42.4
187
- typer==0.12.3
188
- types-python-dateutil==2.9.0.20240316
189
- typing-inspect==0.9.0
190
- typing_extensions==4.12.2
191
- tzdata==2024.1
192
- ujson==5.10.0
193
- uri-template==1.3.0
194
- urllib3==2.2.2
195
- uvicorn==0.30.1
196
- uvloop==0.19.0
197
- watchfiles==0.22.0
198
- wavedrom==2.0.3.post3
199
- wcwidth==0.2.13
200
- webcolors==24.6.0
201
- webencodings==0.5.1
202
- websocket-client==1.8.0
203
- websockets==11.0.3
204
- widgetsnbextension==4.0.11
205
- yarl==1.9.4
 
1
+ openai