vichayturen commented on code in PR #64:
URL:
https://github.com/apache/incubator-hugegraph-ai/pull/64#discussion_r1719923820
##########
hugegraph-llm/src/hugegraph_llm/demo/rag_web_demo.py:
##########
@@ -141,13 +144,141 @@
raise gr.Error(str(e))
-if __name__ == "__main__":
- parser = argparse.ArgumentParser()
- parser.add_argument("--host", type=str, default="0.0.0.0", help="host")
- parser.add_argument("--port", type=int, default=8001, help="port")
- args = parser.parse_args()
- app = FastAPI()
-
+class RAGRequest(BaseModel):
+ query: str
+ raw_llm: Optional[bool] = True
+ vector_only: Optional[bool] = False
+ graph_only: Optional[bool] = False
+ graph_vector: Optional[bool] = False
+
+
+class GraphConfigRequest(BaseModel):
+ ip: str = "127.0.0.1"
+ port: str = "8080"
+ name: str = "hugegraph"
+ user: str = "xxx"
+ pwd: str = "xxx"
+ gs: str = None
+
+
+class LLMConfigRequest(BaseModel):
+ llm_type: str
+ # The common parameters shared by OpenAI, Qianfan Wenxin,
+ # and OLLAMA platforms.
+ api_key: str
+ api_base: str
+ language_model: str
+ # Openai-only properties
+ max_tokens: str = None
+ # qianfan-wenxin-only properties
+ secret_key: str = None
+ # ollama-only properties
+ host: str = None
+ port: str = None
+
+
+def test_api_connection(url, method="GET", headers=None, body=None, auth=None):
+ # TODO: use fastapi.request / starlette instead? (Also add a try-catch
here)
+ response = None
+ log.debug("Request URL: %s", url)
+ if method.upper() == "GET":
+ response = requests.get(url, headers=headers, timeout=5, auth=auth)
Review Comment:
May use some methods to indirectly pass in the URL or disable this rule in
the CodeQL?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]