-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (22 loc) · 1.02 KB
/
main.py
File metadata and controls
31 lines (22 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from autollm import AutoQueryEngine, read_files_as_documents
import openai
# Set OpenAI API key
openai.api_key = 'API_KEY'
# Read files as documents
documents = read_files_as_documents('data')
# Create query engine
query_engine = AutoQueryEngine.from_parameters(
documents=documents,
llm_params={"model": "gpt-3.5-turbo"}
)
# Query
query = 'ما هو الحديث الخامس في الأربعون النووية؟'
# Get the answer
answer = query_engine.query(query)
# Print the answer
print(answer.response)
# Output:
"""
عَنْ أم المؤمنين أم عبد الله عَائِشَةَ ﵂ قَالَتْ: قَالَ رَسُولُ اللَّهِ: «مَنْ أَحْدَثَ فِي أَمْرِنَا هَذَا مَا لَيْسَ مِنْهُ فَهُوَ رَدٌّ» (١) رَوَاهُ الْبُخَارِيُّ، وَمُسْلِمٌ.
وَفِي رِوَايَةٍ لِمُسْلِمٍ: «مَنْ عَمِلَ عَمَلًا لَيْسَ عَلَيْهِ أَمْرُنَا فَهُوَ رَدٌّ».
"""