Spaces:
Sleeping
Sleeping
modernised code
Browse files- app.py +17 -13
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
|
@@ -5,7 +6,10 @@ from huggingface_hub import InferenceClient
|
|
| 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 |
-
client = InferenceClient(
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
def respond(
|
|
@@ -40,7 +44,7 @@ def respond(
|
|
| 40 |
- Knowledge of automation frameworks like Selenium or Robot Framework
|
| 41 |
|
| 42 |
With respect to PHP you are familiar with these advanced concepts and practices:
|
| 43 |
-
|
| 44 |
- Mastery of PHP syntax and features up to the latest PHP versions.
|
| 45 |
- Understanding of advanced PHP features like namespaces, traits, and closures.
|
| 46 |
- Proficiency in error and exception handling.
|
|
@@ -53,7 +57,7 @@ def respond(
|
|
| 53 |
- Experience with template engines like Twig or Blade.
|
| 54 |
- Understanding of Composer, PHP’s dependency manager, and other package managers.
|
| 55 |
- Proficiency in writing unit and integration tests using PHP testing frameworks like PHPUnit.
|
| 56 |
-
|
| 57 |
With respect to Javascript you are familiar with these advanced concepts and practices:
|
| 58 |
|
| 59 |
- Deep understanding of JavaScript ES6+ syntax and features, such as classes, destructuring, template literals, arrow functions, promises, async/await, and modules.
|
|
@@ -62,10 +66,10 @@ def respond(
|
|
| 62 |
- Advanced knowledge of the JavaScript event loop, call stack, context, and execution model.
|
| 63 |
- Proficiency with one or more modern JavaScript frameworks and libraries like React, Angular, Vue.js, or Svelte, including their ecosystems (e.g., Redux, Context API, VueX, NgRx).
|
| 64 |
- Experience with frontend build tools and compilers such as Webpack, Rollup, or Parcel.
|
| 65 |
-
- Strong proficiency in Node.js and frameworks such as Express, Koa, or NestJS.
|
| 66 |
|
| 67 |
With respect to CoffeeScript you are familiar with these advanced concepts and practices:
|
| 68 |
-
|
| 69 |
- Mastery of CoffeeScript syntax and idioms, including significant whitespace and streamlined syntax.
|
| 70 |
- Deep understanding of CoffeeScript's operators and aliases (e.g., `is` for `===`, `isnt` for `!==`, `->` for function declaration).
|
| 71 |
- Knowledge of CoffeeScript's class syntax and inheritance model, which provides a more straightforward syntax for object-oriented programming compared to JavaScript.
|
|
@@ -113,20 +117,20 @@ def respond(
|
|
| 113 |
|
| 114 |
response = ""
|
| 115 |
|
| 116 |
-
|
|
|
|
| 117 |
messages,
|
| 118 |
max_tokens=max_tokens,
|
| 119 |
-
stream=True,
|
| 120 |
temperature=temperature,
|
| 121 |
top_p=top_p,
|
|
|
|
| 122 |
):
|
| 123 |
-
if
|
| 124 |
-
|
| 125 |
-
if
|
| 126 |
-
response +=
|
| 127 |
yield response
|
| 128 |
-
#
|
| 129 |
-
# yield "Please clear the history and try again."
|
| 130 |
|
| 131 |
"""
|
| 132 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
|
|
|
| 1 |
+
import os
|
| 2 |
import gradio as gr
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
|
|
|
| 6 |
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
|
| 7 |
"""
|
| 8 |
# client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 9 |
+
client = InferenceClient(
|
| 10 |
+
"meta-llama/Meta-Llama-3-8B-Instruct",
|
| 11 |
+
token=os.environ.get("HF_TOKEN")
|
| 12 |
+
)
|
| 13 |
|
| 14 |
|
| 15 |
def respond(
|
|
|
|
| 44 |
- Knowledge of automation frameworks like Selenium or Robot Framework
|
| 45 |
|
| 46 |
With respect to PHP you are familiar with these advanced concepts and practices:
|
| 47 |
+
|
| 48 |
- Mastery of PHP syntax and features up to the latest PHP versions.
|
| 49 |
- Understanding of advanced PHP features like namespaces, traits, and closures.
|
| 50 |
- Proficiency in error and exception handling.
|
|
|
|
| 57 |
- Experience with template engines like Twig or Blade.
|
| 58 |
- Understanding of Composer, PHP’s dependency manager, and other package managers.
|
| 59 |
- Proficiency in writing unit and integration tests using PHP testing frameworks like PHPUnit.
|
| 60 |
+
|
| 61 |
With respect to Javascript you are familiar with these advanced concepts and practices:
|
| 62 |
|
| 63 |
- Deep understanding of JavaScript ES6+ syntax and features, such as classes, destructuring, template literals, arrow functions, promises, async/await, and modules.
|
|
|
|
| 66 |
- Advanced knowledge of the JavaScript event loop, call stack, context, and execution model.
|
| 67 |
- Proficiency with one or more modern JavaScript frameworks and libraries like React, Angular, Vue.js, or Svelte, including their ecosystems (e.g., Redux, Context API, VueX, NgRx).
|
| 68 |
- Experience with frontend build tools and compilers such as Webpack, Rollup, or Parcel.
|
| 69 |
+
- Strong proficiency in Node.js and frameworks such as Express, Koa, or NestJS.
|
| 70 |
|
| 71 |
With respect to CoffeeScript you are familiar with these advanced concepts and practices:
|
| 72 |
+
|
| 73 |
- Mastery of CoffeeScript syntax and idioms, including significant whitespace and streamlined syntax.
|
| 74 |
- Deep understanding of CoffeeScript's operators and aliases (e.g., `is` for `===`, `isnt` for `!==`, `->` for function declaration).
|
| 75 |
- Knowledge of CoffeeScript's class syntax and inheritance model, which provides a more straightforward syntax for object-oriented programming compared to JavaScript.
|
|
|
|
| 117 |
|
| 118 |
response = ""
|
| 119 |
|
| 120 |
+
# Stream the model output safely
|
| 121 |
+
for msg in client.chat_completion(
|
| 122 |
messages,
|
| 123 |
max_tokens=max_tokens,
|
|
|
|
| 124 |
temperature=temperature,
|
| 125 |
top_p=top_p,
|
| 126 |
+
stream=True,
|
| 127 |
):
|
| 128 |
+
if hasattr(msg, "choices") and msg.choices:
|
| 129 |
+
delta = msg.choices[0].delta
|
| 130 |
+
if hasattr(delta, "content") and delta.content:
|
| 131 |
+
response += delta.content
|
| 132 |
yield response
|
| 133 |
+
# Ignore any events that do not contain content
|
|
|
|
| 134 |
|
| 135 |
"""
|
| 136 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
requirements.txt
CHANGED
|
@@ -1 +1,2 @@
|
|
| 1 |
-
|
|
|
|
|
|
| 1 |
+
gradio>=4.44.0
|
| 2 |
+
huggingface_hub>=0.23.0
|