Spaces:
Configuration error
Configuration error
| import gradio as gr | |
| from dify_rag import answer_question | |
| def chat_fn(message, history): | |
| result = answer_question(message) | |
| answer = result["answer"] | |
| sources = result.get("sources", []) | |
| if sources: | |
| answer += "\n\nSources:\n" + "\n".join(f"- [{s.get('title', '')}]({s.get('url', '')})" for s in sources if s.get("url")) | |
| return answer | |
| iface = gr.ChatInterface( | |
| fn=chat_fn, | |
| title="Dify Documentation Expert", | |
| description="Ask anything about Dify documentation!", | |
| examples=["What is Dify?", "How do I use code-based extensions?", "What is LLMOps?"] | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() | |