--- 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 integration - `OPENAI_API_KEY`, `OPENAI_ORGANIZATION` - for OpenAI integration - `USE_LANGFUSE`, `LANGFUSE_PRIVATE`, `LANGFUSE_PUBLIC` - for Langfuse integration ### How to integrate - Copy `app` folder to your project (assuming `myapp`) ```bash 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`, and `langfuse` to your `requirements.txt` - Add [environment variables](#environment-variables) to your `.env` file - Use `llm_inference` somewhere in your app `views.py` ```python 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], }) ```