Spaces:
Sleeping
Sleeping
|
Download README.md from PersonaMusicGroup/PersonaAI: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/spaces/PersonaMusicGroup/PersonaAI/resolve/main/README.md
- Command line
-
hf download hf://spaces/PersonaMusicGroup/PersonaAI/README.md
-
curl -L -o README.md https://huggingface.co/spaces/PersonaMusicGroup/PersonaAI/resolve/main/README.md
1.53 kB
metadata
title: Personamusic
emoji: 🔥
colorFrom: green
colorTo: yellow
sdk: docker
sdk_version: 3.50.2
app_file: app/app.py
app_port: 7860
pinned: false
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
Environment variables
CYANITE_ACCESS_TOKEN,CYANITE_WEBHOOK_SECRET- for Cyanite integrationOPENAI_API_KEY,OPENAI_ORGANIZATION- for OpenAI integrationUSE_LANGFUSE,LANGFUSE_PRIVATE,LANGFUSE_PUBLIC- for Langfuse integration
How to integrate
- Copy
appfolder to your project (assumingmyapp)
cp -r app myapp
mv myapp/app myapp/llm_inference
# remove app.py file, we do not need it
rm -rf myapp/llm_inference/app.py
- Add
langchain,openai, andlangfuseto yourrequirements.txt - Add environment variables to your
.envfile - Use
llm_inferencesomewhere in your appviews.py
from dataclasses import asdict
from django.http import HttpRequest, JsonResponse
from myapp.llm_inference.langchain_agent import llm_inference
...
def llm_view(request: HttpRequest) -> JsonResponse :
user_id = request.user.username # any user identifier
response = llm_inference(request.text, user_id)
logger.info(f"User output: {response.output}")
logger.info(f"Tracks: {response.tracks}")
logger.info(f"OpenAI metrics: {response.metrics}")
return JsonResponse({{
"response": response,
"tracks": [asdict(i) for i in response.tracks],
})