geronimo-pericoli commited on
Commit
55153f6
·
verified ·
1 Parent(s): 076713f

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +35 -2
server.py CHANGED
@@ -5,11 +5,45 @@ from llama_index.core import (
5
  StorageContext,
6
  load_index_from_storage,
7
  )
 
 
 
8
  from typing import Dict, Optional
9
  import json
10
  import os
11
  import aiohttp # Necesario para las peticiones HTTP asíncronas
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  port = int(os.getenv("PORT", 7860))
14
  mcp = FastMCP("OnBase", port=port)
15
 
@@ -56,8 +90,7 @@ for source, rel_path in SOURCES.items():
56
  uri="retriever://documentos/{fuente}",
57
  name="DocumentRetriever",
58
  description="Retrieve documents from different regulations using semantic search.",
59
- mime_type="application/json",
60
- tags={"llm", "retrieval"}
61
  )
62
  def retrieve_docs(query: str, fuente: str = 'oms', top_k: int = 3) -> dict:
63
  """
 
5
  StorageContext,
6
  load_index_from_storage,
7
  )
8
+ from llama_index.core import Settings
9
+ from llama_index.llms.azure_openai import AzureOpenAI
10
+ from llama_index.embeddings.azure_openai import AzureOpenAIEmbedding
11
  from typing import Dict, Optional
12
  import json
13
  import os
14
  import aiohttp # Necesario para las peticiones HTTP asíncronas
15
 
16
+
17
+
18
+
19
+ api_key = os.environ.get('AZURE_API_KEY')
20
+ azure_endpoint = "https://pharmaia-gpt.openai.azure.com/"
21
+ api_version = "2024-02-01"
22
+
23
+ llm = AzureOpenAI(
24
+ model="gpt-4.1",
25
+ deployment_name="gpt-4.1",
26
+ api_key=api_key,
27
+ azure_endpoint=azure_endpoint,
28
+ api_version=api_version,
29
+ )
30
+ # You need to deploy your own embedding model as well as your own chat completion model
31
+ embed_model = AzureOpenAIEmbedding(
32
+ model="text-embedding-3-large",
33
+ deployment_name="text-embedding-3-large",
34
+ api_key=api_key,
35
+ azure_endpoint=azure_endpoint,
36
+ api_version=api_version,
37
+ )
38
+
39
+ Settings.llm = llm
40
+ Settings.embed_model = embed_model
41
+
42
+
43
+
44
+
45
+
46
+
47
  port = int(os.getenv("PORT", 7860))
48
  mcp = FastMCP("OnBase", port=port)
49
 
 
90
  uri="retriever://documentos/{fuente}",
91
  name="DocumentRetriever",
92
  description="Retrieve documents from different regulations using semantic search.",
93
+ mime_type="application/json"
 
94
  )
95
  def retrieve_docs(query: str, fuente: str = 'oms', top_k: int = 3) -> dict:
96
  """