Spaces:
Runtime error
Runtime error
fix: switch explain to Groq free tier
Browse files- pipeline/explainer.py +5 -4
pipeline/explainer.py
CHANGED
|
@@ -29,17 +29,18 @@ class FallacyExplainer:
|
|
| 29 |
DEFAULT_FALLACY_CLASSES = list(FALLACY_DEFINITIONS.keys())
|
| 30 |
|
| 31 |
def __init__(self, fallacy_classes=None, fallacy_definitions=None):
|
| 32 |
-
|
| 33 |
self._client = InferenceClient(
|
| 34 |
-
|
| 35 |
-
|
| 36 |
)
|
| 37 |
self.fallacy_classes = fallacy_classes or self.DEFAULT_FALLACY_CLASSES
|
| 38 |
self.fallacy_definitions = fallacy_definitions or FALLACY_DEFINITIONS
|
| 39 |
-
print(f"FallacyExplainer ready (model: {
|
| 40 |
|
| 41 |
def _generate_with_prompt(self, prompt_text, max_new_tokens=128):
|
| 42 |
result = self._client.chat_completion(
|
|
|
|
| 43 |
messages=[{"role": "user", "content": prompt_text}],
|
| 44 |
max_tokens=max_new_tokens,
|
| 45 |
temperature=0.1,
|
|
|
|
| 29 |
DEFAULT_FALLACY_CLASSES = list(FALLACY_DEFINITIONS.keys())
|
| 30 |
|
| 31 |
def __init__(self, fallacy_classes=None, fallacy_definitions=None):
|
| 32 |
+
self._model_id = os.environ.get("EXPLAIN_MODEL_ID", DEFAULT_MODEL_ID)
|
| 33 |
self._client = InferenceClient(
|
| 34 |
+
provider="groq",
|
| 35 |
+
api_key=os.environ["GROQ_API_KEY"],
|
| 36 |
)
|
| 37 |
self.fallacy_classes = fallacy_classes or self.DEFAULT_FALLACY_CLASSES
|
| 38 |
self.fallacy_definitions = fallacy_definitions or FALLACY_DEFINITIONS
|
| 39 |
+
print(f"FallacyExplainer ready (model: {self._model_id} via Groq)")
|
| 40 |
|
| 41 |
def _generate_with_prompt(self, prompt_text, max_new_tokens=128):
|
| 42 |
result = self._client.chat_completion(
|
| 43 |
+
model=self._model_id,
|
| 44 |
messages=[{"role": "user", "content": prompt_text}],
|
| 45 |
max_tokens=max_new_tokens,
|
| 46 |
temperature=0.1,
|