AGiorni commited on
Commit
45b9751
·
1 Parent(s): 2d3748f

fixed OpenAI keys

Browse files
__pycache__/tools.cpython-313.pyc CHANGED
Binary files a/__pycache__/tools.cpython-313.pyc and b/__pycache__/tools.cpython-313.pyc differ
 
tools.py CHANGED
@@ -5,6 +5,11 @@ from langchain_community.document_loaders import WikipediaLoader
5
  from langchain.text_splitter import RecursiveCharacterTextSplitter
6
  from langchain_chroma import Chroma
7
  from langchain_openai import AzureOpenAIEmbeddings
 
 
 
 
 
8
 
9
  duckduck_tool = Tool(
10
  name="duckduckgo_search",
@@ -17,15 +22,12 @@ wikipedia = WikipediaAPIWrapper(top_k_results=1,doc_content_chars_max=3000)
17
  wikipedia_tool = WikipediaQueryRun(api_wrapper=wikipedia)
18
 
19
 
20
-
21
-
22
-
23
  embeddings = AzureOpenAIEmbeddings(
24
  model="text-embedding-3-large",
25
  # dimensions: Optional[int] = None, # Can specify dimensions with new text-embedding-3 models
26
- # azure_endpoint="https://<your-endpoint>.openai.azure.com/", If not provided, will read env variable AZURE_OPENAI_ENDPOINT
27
- # api_key=... # Can provide an API key directly. If missing read env variable AZURE_OPENAI_API_KEY
28
- # openai_api_version=..., # If not provided, will read env variable AZURE_OPENAI_API_VERSION
29
  )
30
 
31
  def wiki_RAG(query: str):
 
5
  from langchain.text_splitter import RecursiveCharacterTextSplitter
6
  from langchain_chroma import Chroma
7
  from langchain_openai import AzureOpenAIEmbeddings
8
+ import os
9
+ from dotenv import load_dotenv
10
+
11
+ # load environment variables
12
+ load_dotenv() # take environment variables
13
 
14
  duckduck_tool = Tool(
15
  name="duckduckgo_search",
 
22
  wikipedia_tool = WikipediaQueryRun(api_wrapper=wikipedia)
23
 
24
 
 
 
 
25
  embeddings = AzureOpenAIEmbeddings(
26
  model="text-embedding-3-large",
27
  # dimensions: Optional[int] = None, # Can specify dimensions with new text-embedding-3 models
28
+ azure_endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT"),
29
+ api_key = os.environ.get("AZURE_OPENAI_API_KEY"),
30
+ openai_api_version=os.environ.get("OPENAI_API_VERSION")
31
  )
32
 
33
  def wiki_RAG(query: str):
tools_test.ipynb CHANGED
@@ -59,7 +59,7 @@
59
  },
60
  {
61
  "cell_type": "code",
62
- "execution_count": 4,
63
  "id": "3f538870",
64
  "metadata": {},
65
  "outputs": [],
@@ -69,7 +69,7 @@
69
  },
70
  {
71
  "cell_type": "code",
72
- "execution_count": 5,
73
  "id": "ef465273",
74
  "metadata": {},
75
  "outputs": [
@@ -77,13 +77,24 @@
77
  "name": "stdout",
78
  "output_type": "stream",
79
  "text": [
80
- "Page: Chancellor of Germany\n",
81
- "Summary: The chancellor of Germany, officially the federal chancellor of the Federal Republic of Germany, is the head of the federal government of Germany. The chancellor is the chief executive of the Federal Cabinet and heads the executive branch. The chancellor is elect\n"
 
 
 
 
 
 
 
 
 
 
 
82
  ]
83
  }
84
  ],
85
  "source": [
86
- "print(out)"
87
  ]
88
  },
89
  {
 
59
  },
60
  {
61
  "cell_type": "code",
62
+ "execution_count": 28,
63
  "id": "3f538870",
64
  "metadata": {},
65
  "outputs": [],
 
69
  },
70
  {
71
  "cell_type": "code",
72
+ "execution_count": 29,
73
  "id": "ef465273",
74
  "metadata": {},
75
  "outputs": [
 
77
  "name": "stdout",
78
  "output_type": "stream",
79
  "text": [
80
+ "Page: Chancellor of Germany Summary: The chancellor of Germany, officially\n",
81
+ "the federal chancellor of the Federal Republic of Germany, is the head of\n",
82
+ "the federal government of Germany. The chancellor is the chief executive of\n",
83
+ "the Federal Cabinet and heads the executive branch. The chancellor is\n",
84
+ "elected by the Bundestag on the proposal of the federal president and\n",
85
+ "without debate (Article 63 of the German Constitution). During a state of\n",
86
+ "defence declared by the Bundestag the chancellor also assumes the position\n",
87
+ "of commander-in-chief of the Bundeswehr. Ten people (nine men and one\n",
88
+ "woman) have served as chancellor of the Federal Republic of Germany, the\n",
89
+ "first being Konrad Adenauer from 1949 to 1963. (Another 26 men had served\n",
90
+ "as \"Reich chancellors\" of the previous German Empire from 1871 to 1945.)\n",
91
+ "The current officeholder is Friedrich Merz of the Christian Democratic\n",
92
+ "Union, sworn in on 6 May 2025.\n"
93
  ]
94
  }
95
  ],
96
  "source": [
97
+ "print_(out)"
98
  ]
99
  },
100
  {