mackenzietechdocs commited on
Commit
e9c63c4
·
1 Parent(s): 428aa76

Use free open models via Hugging Face Inference Providers with Sign in with Hugging Face; credit DevRubenArevalo

Browse files
Files changed (6) hide show
  1. .env.example +3 -4
  2. LIVE_COPY_FIXES.md +4 -3
  3. README.md +23 -4
  4. app.py +95 -43
  5. requirements.txt +1 -2
  6. test_api.py +17 -18
.env.example CHANGED
@@ -1,4 +1,3 @@
1
- ANTHROPIC_API_KEY=your_api_key_here
2
- # Optional: override the default Claude model (claude-haiku-5-5).
3
- # The original default, claude-3-haiku-20240307, was retired on 20 April 2026.
4
- # ANTHROPIC_MODEL=claude-haiku-5-5
 
1
+ # The Gradio app needs no API key: visitors sign in with Hugging Face and use their own free allowance.
2
+ # Optional: choose a different open chat model served by HF Inference Providers.
3
+ # HEALIXPATH_MODEL=openai/gpt-oss-20b
 
LIVE_COPY_FIXES.md CHANGED
@@ -5,9 +5,10 @@ Do not push these to MCP-1st-Birthday/TeamHealix.
5
  Changes vs the November 2025 submission:
6
  - Pin Python deps so a fresh Space build is reproducible.
7
  - Install `gradio[mcp]==5.49.1` and launch with `mcp_server=True` so the
8
- MCP endpoint is `https://teamhealix-healixpath.hf.space/gradio_api/mcp/`.
9
- - Default `ANTHROPIC_MODEL` is `claude-haiku-5-5` because
10
- `claude-3-haiku-20240307` was retired on 20 April 2026.
 
11
  - Remove an unused `subprocess` import.
12
 
13
  The TypeScript MCP server under `src/` is a local demo (no official MCP
 
5
  Changes vs the November 2025 submission:
6
  - Pin Python deps so a fresh Space build is reproducible.
7
  - Install `gradio[mcp]==5.49.1` and launch with `mcp_server=True` so the
8
+ MCP endpoint is `https://mackenzietechdocs-healixpath.hf.space/gradio_api/mcp/`.
9
+ - AI backend: the Anthropic client was removed. Generation uses open models through
10
+ Hugging Face Inference Providers with each visitor's own token (Sign in with Hugging Face),
11
+ so no API key or Space secret is needed. (The original model, `claude-3-haiku-20240307`, was retired on 20 April 2026.)
12
  - Remove an unused `subprocess` import.
13
 
14
  The TypeScript MCP server under `src/` is a local demo (no official MCP
README.md CHANGED
@@ -7,6 +7,9 @@ sdk: gradio
7
  sdk_version: 5.49.1
8
  app_file: app.py
9
  pinned: true
 
 
 
10
  short_description: AI-powered persona storytelling engine for enterprise.
11
  tags:
12
  - mcp-hackathon
@@ -24,7 +27,23 @@ tags:
24
 
25
  ## About The Team
26
 
27
- [@DevRubenArevalo](https://huggingface.co/DevRubenArevalo) and [@mackenzietechdocs](https://huggingface.co/mackenzietechdocs) are Team Healix! We are a two-person dev team looking to make robust AI applications for everyone.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
 
30
  ## The Posts
@@ -53,7 +72,7 @@ Designed to help product teams feel their users, not just document them.
53
 
54
  ## 🛠️ 2. MCP-Compatible Tools
55
 
56
- Each tool is exposed through the MCP server (`src/index.ts`) and powered by Claude via the `@anthropic-sdk/sdk`. Schemas are enforced through Anthropic's JSON mode so outputs are always valid.
57
 
58
  ### 1. `list_personas`
59
  Lists all available personas with their key attributes.
@@ -336,12 +355,12 @@ healixpath/
336
 
337
  ### Node.js MCP Server
338
  ```bash
339
- cp .env.example .env # add your Anthropic key
340
  npm install
341
  npm run build
342
  npm run start
343
  ```
344
- `src/index.ts` boots the HealixPath MCP server, enumerates tools, and shows sample tool calls. Claude responses stream through `@anthropic-sdk/sdk` with enforced JSON schemas; when the API key is absent, deterministic fallbacks keep the demo running.
345
 
346
  ### Gradio Demo
347
  ```bash
 
7
  sdk_version: 5.49.1
8
  app_file: app.py
9
  pinned: true
10
+ hf_oauth: true
11
+ hf_oauth_scopes:
12
+ - inference-api
13
  short_description: AI-powered persona storytelling engine for enterprise.
14
  tags:
15
  - mcp-hackathon
 
27
 
28
  ## About The Team
29
 
30
+ HealixPath was built by **Mackenzie O'Brien** ([@mackenzietechdocs](https://huggingface.co/mackenzietechdocs), [GitHub](https://github.com/mso-docs)) and **co-author @DevRubenArevalo** ([Hugging Face](https://huggingface.co/DevRubenArevalo), [GitHub](https://github.com/DevRubenArevalo)). Together we are Team Healix, a two-person dev team looking to make robust AI applications for everyone.
31
+
32
+ The official November 2025 hackathon submission lives at [MCP-1st-Birthday/TeamHealix](https://huggingface.co/spaces/MCP-1st-Birthday/TeamHealix) and is kept unchanged. This Space is the live, maintained copy.
33
+
34
+ ## Sign in with Hugging Face (free AI, no API key)
35
+
36
+ This live copy no longer uses any paid API key. Text generation runs on open models through [Hugging Face Inference Providers](https://huggingface.co/docs/inference-providers), using **your own** Hugging Face account:
37
+
38
+ 1. Click **Sign in with Hugging Face** at the top of the app and approve the `inference-api` permission.
39
+ 2. Generate stories, journeys, and personas. Each request is billed to your account's free monthly Inference Providers allowance. If you run out, Hugging Face will tell you; PRO accounts get a larger allowance.
40
+ 3. Signed-out visitors can browse and search personas, but generation shows a "please sign in" message. The Space never falls back to its owner's token or any secret.
41
+
42
+ Model: [`openai/gpt-oss-20b`](https://huggingface.co/openai/gpt-oss-20b) (open weights, Apache 2.0, instruction-tuned). When running your own copy, set the `HEALIXPATH_MODEL` environment variable to any chat model served by Inference Providers.
43
+
44
+ **MCP clients:** the Gradio MCP endpoint is `https://mackenzietechdocs-healixpath.hf.space/gradio_api/mcp/`. Tools that generate text need a Hugging Face token with the "Make calls to Inference Providers" permission; send it as `Authorization: Bearer <your token>`.
45
+
46
+ **Running locally:** `pip install -r requirements.txt && python app.py`. Local OAuth sign-in needs a Space; the app does not read `HF_TOKEN`. Duplicate the Space to your account to get your own copy with sign-in enabled.
47
 
48
 
49
  ## The Posts
 
72
 
73
  ## 🛠️ 2. MCP-Compatible Tools
74
 
75
+ Each tool is exposed through the MCP server (`src/index.ts`) and powered by open models via Hugging Face Inference Providers in the Gradio app (the original hackathon build used Claude). Prompts request JSON-only output.
76
 
77
  ### 1. `list_personas`
78
  Lists all available personas with their key attributes.
 
355
 
356
  ### Node.js MCP Server
357
  ```bash
358
+ cp .env.example .env # optional: only the original local Node demo used an Anthropic key
359
  npm install
360
  npm run build
361
  npm run start
362
  ```
363
+ `src/index.ts` boots the HealixPath MCP server, enumerates tools, and shows sample tool calls. This local TypeScript demo is the original hackathon prototype; the live Gradio app does not use it.
364
 
365
  ### Gradio Demo
366
  ```bash
app.py CHANGED
@@ -7,9 +7,10 @@ A web interface for generating AI-powered persona-driven narratives.
7
  import gradio as gr
8
  import json
9
  import os
 
10
  from pathlib import Path
11
  from dotenv import load_dotenv
12
- from anthropic import Anthropic
13
 
14
  # Modern CSS styling
15
  CUSTOM_CSS = """
@@ -540,10 +541,17 @@ persona_list = list(persona_options.keys())
540
  persona_choices = [CUSTOM_PERSONA_LABEL] + persona_list
541
  default_persona_choice = persona_list[0] if persona_list else CUSTOM_PERSONA_LABEL
542
 
543
- # Initialize Anthropic client
544
- api_key = os.getenv("ANTHROPIC_API_KEY")
545
- model = os.getenv("ANTHROPIC_MODEL", "claude-haiku-5-5")
546
- client = Anthropic(api_key=api_key) if api_key else None
 
 
 
 
 
 
 
547
 
548
  def get_persona_context(persona_id: str, custom_persona: str = "") -> str:
549
  """Format persona data for prompt context."""
@@ -630,32 +638,59 @@ def toggle_custom_persona(selected_value: str):
630
  show_custom = selected_value == CUSTOM_PERSONA_LABEL
631
  return gr.update(visible=show_custom, value="" if not show_custom else None)
632
 
633
- def generate_with_claude(system_prompt: str, user_prompt: str) -> str:
634
- """Call Claude API and return structured response."""
635
- if not client or not api_key:
636
- return json.dumps({
637
- "error": "ANTHROPIC_API_KEY not configured",
638
- "message": "Please add your ANTHROPIC_API_KEY to the .env file"
639
- }, indent=2)
640
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
641
  try:
642
- message = client.messages.create(
643
- model=model,
644
- max_tokens=1024,
645
- system=system_prompt,
646
  messages=[
647
- {"role": "user", "content": user_prompt}
648
- ]
 
 
 
649
  )
650
- return message.content[0].text
651
  except Exception as e:
652
  return json.dumps({
653
- "error": str(type(e).__name__),
654
- "message": str(e)
655
  }, indent=2)
656
 
657
- def generate_user_story(product: str, persona_name: str, persona_override: str):
 
658
  """Generate a user story for the given product and persona(s)."""
 
659
  _, persona_contexts = build_persona_profile(persona_name, persona_override)
660
 
661
  system_prompt = """You are an expert UX writer and product strategist.
@@ -674,7 +709,7 @@ Generate a user story for this persona using the product: {product}
674
 
675
  Format as JSON with the keys: story, acceptance_criteria (array), risks (array)"""
676
 
677
- response = generate_with_claude(system_prompt, user_prompt)
678
  try:
679
  data = json.loads(response)
680
  if len(persona_contexts) > 1:
@@ -685,8 +720,10 @@ Format as JSON with the keys: story, acceptance_criteria (array), risks (array)"
685
 
686
  return json.dumps(results if len(results) > 1 else results[0], indent=2)
687
 
688
- def generate_experience_tale(problem: str, persona_name: str, persona_override: str):
 
689
  """Generate a customer experience tale."""
 
690
  _, persona_contexts = build_persona_profile(persona_name, persona_override)
691
 
692
  system_prompt = """You are an expert in customer experience and user research.
@@ -706,7 +743,7 @@ Describe how this persona experiences this problem: {problem}
706
 
707
  Format as JSON with keys: title, narrative, pain_points (array), opportunities (array)"""
708
 
709
- response = generate_with_claude(system_prompt, user_prompt)
710
  try:
711
  data = json.loads(response)
712
  if len(persona_contexts) > 1:
@@ -717,8 +754,10 @@ Format as JSON with keys: title, narrative, pain_points (array), opportunities (
717
 
718
  return json.dumps(results if len(results) > 1 else results[0], indent=2)
719
 
720
- def generate_feature_impact(feature: str, persona_name: str, persona_override: str):
 
721
  """Generate a before/after feature impact story."""
 
722
  _, persona_contexts = build_persona_profile(persona_name, persona_override)
723
 
724
  system_prompt = """You are an expert at showing product impact through user narratives.
@@ -738,7 +777,7 @@ Show the before/after impact of this feature on the persona's experience: {featu
738
 
739
  Format as JSON with keys: before_story, after_story, key_benefits (array), success_metrics (array)"""
740
 
741
- response = generate_with_claude(system_prompt, user_prompt)
742
  try:
743
  data = json.loads(response)
744
  if len(persona_contexts) > 1:
@@ -749,8 +788,10 @@ Format as JSON with keys: before_story, after_story, key_benefits (array), succe
749
 
750
  return json.dumps(results if len(results) > 1 else results[0], indent=2)
751
 
752
- def generate_journey_story(stage: str, product: str, persona_name: str, persona_override: str):
 
753
  """Generate a journey map narrative."""
 
754
  _, persona_contexts = build_persona_profile(persona_name, persona_override)
755
 
756
  system_prompt = """You are an expert in customer journey mapping and experience design.
@@ -772,7 +813,7 @@ Describe this persona's experience at the '{stage}' stage of their journey with
772
 
773
  Format as JSON with keys: stage, narrative, touchpoints (array), emotions (array), breakdowns (array), opportunities (array)"""
774
 
775
- response = generate_with_claude(system_prompt, user_prompt)
776
  try:
777
  data = json.loads(response)
778
  if len(persona_contexts) > 1:
@@ -865,16 +906,18 @@ def show_persona_details(persona_index: int):
865
  return json.dumps(p, indent=2)
866
  return "Persona not found"
867
 
868
- def generate_personas_func(description: str, count: int):
869
- """Generate random personas based on description using Claude AI."""
 
 
870
  if not description or not description.strip():
871
  return json.dumps({"error": "Please provide a description"}, indent=2)
872
 
873
  if count < 1 or count > 5:
874
  return json.dumps({"error": "Count must be between 1 and 5"}, indent=2)
875
 
876
- if not client:
877
- return json.dumps({"error": "Anthropic API key not configured"}, indent=2)
878
 
879
  system_prompt = """You are a persona generation expert. Generate realistic, diverse user personas based on the provided description.
880
 
@@ -952,14 +995,10 @@ Requirements:
952
  Return format: [persona1, persona2, ...]"""
953
 
954
  try:
955
- response = client.messages.create(
956
- model=model,
957
- max_tokens=4096,
958
- messages=[{"role": "user", "content": f"{system_prompt}\n\n{user_prompt}"}]
959
- )
960
-
961
- response_text = response.content[0].text if response.content else ""
962
-
963
  # Clean up response (remove markdown code blocks if present)
964
  cleaned_response = response_text.strip()
965
  if cleaned_response.startswith("```json"):
@@ -989,6 +1028,19 @@ with gr.Blocks(title="HealixPath - AI Persona Storytelling", css=CUSTOM_CSS) as
989
  """
990
  )
991
 
 
 
 
 
 
 
 
 
 
 
 
 
 
992
  gr.HTML(
993
  """
994
  <div class="card-container" style="margin-bottom: 26px;">
@@ -1259,7 +1311,7 @@ with gr.Blocks(title="HealixPath - AI Persona Storytelling", css=CUSTOM_CSS) as
1259
  <div style="text-align: center; margin-top: 32px; padding: 16px; border-top: 1px solid var(--line); color: var(--text-dim);">
1260
  <p style="font-size: 13px; margin: 0;">
1261
  HealixPath - AI-powered persona storytelling engine<br>
1262
- <span style="color: var(--muted);">Powered by Claude &amp; Gradio</span>
1263
  </p>
1264
  </div>
1265
  """
 
7
  import gradio as gr
8
  import json
9
  import os
10
+ import re
11
  from pathlib import Path
12
  from dotenv import load_dotenv
13
+ from huggingface_hub import InferenceClient
14
 
15
  # Modern CSS styling
16
  CUSTOM_CSS = """
 
541
  persona_choices = [CUSTOM_PERSONA_LABEL] + persona_list
542
  default_persona_choice = persona_list[0] if persona_list else CUSTOM_PERSONA_LABEL
543
 
544
+ # Free AI backend: Hugging Face Inference Providers.
545
+ # Every generation runs on the *visitor's* Hugging Face account (Sign in with Hugging Face),
546
+ # so it uses the visitor's own free monthly allowance. The Space never uses its own token,
547
+ # a Space secret, or a paid API key for inference.
548
+ MODEL = os.getenv("HEALIXPATH_MODEL", "openai/gpt-oss-20b")
549
+
550
+ SIGN_IN_MESSAGE = (
551
+ "Please sign in with Hugging Face (button at the top of the page) to generate. "
552
+ "Generations use your own free Hugging Face Inference Providers allowance."
553
+ )
554
+
555
 
556
  def get_persona_context(persona_id: str, custom_persona: str = "") -> str:
557
  """Format persona data for prompt context."""
 
638
  show_custom = selected_value == CUSTOM_PERSONA_LABEL
639
  return gr.update(visible=show_custom, value="" if not show_custom else None)
640
 
641
+ def resolve_token(oauth_token=None, request=None):
642
+ """Return the visitor's own Hugging Face token, or None.
643
+
644
+ Order: the OAuth token from "Sign in with Hugging Face", then a Bearer token the
645
+ caller sent in the Authorization header (for MCP clients that pass their own token).
646
+ Never falls back to a Space-level token or secret.
647
+ """
648
+ token = getattr(oauth_token, "token", None)
649
+ if token:
650
+ return token
651
+ try:
652
+ auth = request.headers.get("authorization", "") if request is not None else ""
653
+ except Exception:
654
+ auth = ""
655
+ if auth.lower().startswith("bearer ") and auth[7:].strip():
656
+ return auth[7:].strip()
657
+ return None
658
+
659
+
660
+ def _strip_code_fence(text: str) -> str:
661
+ text = (text or "").strip()
662
+ if text.startswith("```"):
663
+ text = re.sub(r"^```[a-zA-Z]*\s*", "", text)
664
+ text = re.sub(r"\s*```$", "", text).strip()
665
+ return text
666
+
667
+
668
+ def generate_text(system_prompt: str, user_prompt: str, token, max_tokens: int = 1500) -> str:
669
+ """Call an open model through HF Inference Providers with the visitor's token."""
670
+ if not token:
671
+ return json.dumps({"error": "Sign in required", "message": SIGN_IN_MESSAGE}, indent=2)
672
  try:
673
+ client = InferenceClient(api_key=token)
674
+ result = client.chat_completion(
675
+ model=MODEL,
 
676
  messages=[
677
+ {"role": "system", "content": system_prompt},
678
+ {"role": "user", "content": user_prompt},
679
+ ],
680
+ max_tokens=max_tokens,
681
+ temperature=0.7,
682
  )
683
+ return _strip_code_fence(result.choices[0].message.content or "")
684
  except Exception as e:
685
  return json.dumps({
686
+ "error": type(e).__name__,
687
+ "message": f"Hugging Face Inference Providers call failed: {e}",
688
  }, indent=2)
689
 
690
+ def generate_user_story(product: str, persona_name: str, persona_override: str,
691
+ oauth_token: gr.OAuthToken | None = None, request: gr.Request = None):
692
  """Generate a user story for the given product and persona(s)."""
693
+ token = resolve_token(oauth_token, request)
694
  _, persona_contexts = build_persona_profile(persona_name, persona_override)
695
 
696
  system_prompt = """You are an expert UX writer and product strategist.
 
709
 
710
  Format as JSON with the keys: story, acceptance_criteria (array), risks (array)"""
711
 
712
+ response = generate_text(system_prompt, user_prompt, token)
713
  try:
714
  data = json.loads(response)
715
  if len(persona_contexts) > 1:
 
720
 
721
  return json.dumps(results if len(results) > 1 else results[0], indent=2)
722
 
723
+ def generate_experience_tale(problem: str, persona_name: str, persona_override: str,
724
+ oauth_token: gr.OAuthToken | None = None, request: gr.Request = None):
725
  """Generate a customer experience tale."""
726
+ token = resolve_token(oauth_token, request)
727
  _, persona_contexts = build_persona_profile(persona_name, persona_override)
728
 
729
  system_prompt = """You are an expert in customer experience and user research.
 
743
 
744
  Format as JSON with keys: title, narrative, pain_points (array), opportunities (array)"""
745
 
746
+ response = generate_text(system_prompt, user_prompt, token)
747
  try:
748
  data = json.loads(response)
749
  if len(persona_contexts) > 1:
 
754
 
755
  return json.dumps(results if len(results) > 1 else results[0], indent=2)
756
 
757
+ def generate_feature_impact(feature: str, persona_name: str, persona_override: str,
758
+ oauth_token: gr.OAuthToken | None = None, request: gr.Request = None):
759
  """Generate a before/after feature impact story."""
760
+ token = resolve_token(oauth_token, request)
761
  _, persona_contexts = build_persona_profile(persona_name, persona_override)
762
 
763
  system_prompt = """You are an expert at showing product impact through user narratives.
 
777
 
778
  Format as JSON with keys: before_story, after_story, key_benefits (array), success_metrics (array)"""
779
 
780
+ response = generate_text(system_prompt, user_prompt, token)
781
  try:
782
  data = json.loads(response)
783
  if len(persona_contexts) > 1:
 
788
 
789
  return json.dumps(results if len(results) > 1 else results[0], indent=2)
790
 
791
+ def generate_journey_story(stage: str, product: str, persona_name: str, persona_override: str,
792
+ oauth_token: gr.OAuthToken | None = None, request: gr.Request = None):
793
  """Generate a journey map narrative."""
794
+ token = resolve_token(oauth_token, request)
795
  _, persona_contexts = build_persona_profile(persona_name, persona_override)
796
 
797
  system_prompt = """You are an expert in customer journey mapping and experience design.
 
813
 
814
  Format as JSON with keys: stage, narrative, touchpoints (array), emotions (array), breakdowns (array), opportunities (array)"""
815
 
816
+ response = generate_text(system_prompt, user_prompt, token)
817
  try:
818
  data = json.loads(response)
819
  if len(persona_contexts) > 1:
 
906
  return json.dumps(p, indent=2)
907
  return "Persona not found"
908
 
909
+ def generate_personas_func(description: str, count: int,
910
+ oauth_token: gr.OAuthToken | None = None, request: gr.Request = None):
911
+ """Generate random personas based on description using an open model via Hugging Face."""
912
+ token = resolve_token(oauth_token, request)
913
  if not description or not description.strip():
914
  return json.dumps({"error": "Please provide a description"}, indent=2)
915
 
916
  if count < 1 or count > 5:
917
  return json.dumps({"error": "Count must be between 1 and 5"}, indent=2)
918
 
919
+ if not token:
920
+ return json.dumps({"error": "Sign in required", "message": SIGN_IN_MESSAGE}, indent=2)
921
 
922
  system_prompt = """You are a persona generation expert. Generate realistic, diverse user personas based on the provided description.
923
 
 
995
  Return format: [persona1, persona2, ...]"""
996
 
997
  try:
998
+ response_text = generate_text(system_prompt, user_prompt, token, max_tokens=4096)
999
+ if response_text.lstrip().startswith("{") and '"error"' in response_text[:40]:
1000
+ return response_text
1001
+
 
 
 
 
1002
  # Clean up response (remove markdown code blocks if present)
1003
  cleaned_response = response_text.strip()
1004
  if cleaned_response.startswith("```json"):
 
1028
  """
1029
  )
1030
 
1031
+ with gr.Row():
1032
+ gr.LoginButton(value="Sign in with Hugging Face")
1033
+ signin_status = gr.Markdown(
1034
+ "**Signed out.** " + SIGN_IN_MESSAGE
1035
+ )
1036
+
1037
+ def show_signin_status(profile: gr.OAuthProfile | None):
1038
+ if profile is None:
1039
+ return "**Signed out.** " + SIGN_IN_MESSAGE
1040
+ return f"**Signed in as {profile.username}.** Generations use your own free Hugging Face allowance."
1041
+
1042
+ demo.load(show_signin_status, inputs=None, outputs=signin_status)
1043
+
1044
  gr.HTML(
1045
  """
1046
  <div class="card-container" style="margin-bottom: 26px;">
 
1311
  <div style="text-align: center; margin-top: 32px; padding: 16px; border-top: 1px solid var(--line); color: var(--text-dim);">
1312
  <p style="font-size: 13px; margin: 0;">
1313
  HealixPath - AI-powered persona storytelling engine<br>
1314
+ <span style="color: var(--muted);">Open models via Hugging Face Inference Providers &amp; Gradio</span>
1315
  </p>
1316
  </div>
1317
  """
requirements.txt CHANGED
@@ -1,4 +1,3 @@
1
- gradio[mcp]==5.49.1
2
- anthropic==2.8.0
3
  pydantic==2.11.10
4
  python-dotenv==1.2.4
 
1
+ gradio[mcp,oauth]==5.49.1
 
2
  pydantic==2.11.10
3
  python-dotenv==1.2.4
test_api.py CHANGED
@@ -1,28 +1,27 @@
1
  #!/usr/bin/env python3
2
- import os
3
- from dotenv import load_dotenv
4
- from anthropic import Anthropic
5
 
6
- load_dotenv()
7
- api_key = os.getenv('ANTHROPIC_API_KEY')
8
- model = os.getenv('ANTHROPIC_MODEL', 'claude-haiku-5-5')
 
9
 
10
- print(f'API Key found: {bool(api_key)}')
11
- print(f'API Key (first 20 chars): {api_key[:20] if api_key else "None"}')
12
- print(f'Model: {model}')
 
13
 
14
- if api_key:
15
  try:
16
- client = Anthropic(api_key=api_key)
17
- response = client.messages.create(
18
  model=model,
 
19
  max_tokens=100,
20
- messages=[{'role': 'user', 'content': 'Say hello'}]
21
  )
22
- print(f'✅ API call successful!')
23
- print(f'Response: {response.content[0].text}')
24
  except Exception as e:
25
- print(f'❌ API Error: {type(e).__name__}')
26
- print(f'Message: {str(e)}')
27
  else:
28
- print('❌ No API key found')
 
1
  #!/usr/bin/env python3
2
+ """Dev-only smoke test: calls the HealixPath model with a token you supply via HF_TOKEN.
 
 
3
 
4
+ The app itself never reads HF_TOKEN; visitors sign in with Hugging Face instead.
5
+ """
6
+ import os
7
+ from huggingface_hub import InferenceClient
8
 
9
+ model = os.getenv("HEALIXPATH_MODEL", "openai/gpt-oss-20b")
10
+ token = os.getenv("HF_TOKEN")
11
+ print(f"Model: {model}")
12
+ print(f"HF_TOKEN set: {bool(token)}")
13
 
14
+ if token:
15
  try:
16
+ result = InferenceClient(api_key=token).chat_completion(
 
17
  model=model,
18
+ messages=[{"role": "user", "content": "Say hello"}],
19
  max_tokens=100,
 
20
  )
21
+ print("API call successful")
22
+ print(f"Response: {result.choices[0].message.content}")
23
  except Exception as e:
24
+ print(f"API error: {type(e).__name__}")
25
+ print(f"Message: {e}")
26
  else:
27
+ print("Set HF_TOKEN (needs the 'Make calls to Inference Providers' permission) to run this check.")