Spaces:
Running
Running
sachin
commited on
Commit
·
e84e439
1
Parent(s):
c0961f5
update-country tax data
Browse files- taxtech/urls.py +3 -1
- taxtech/views.py +69 -0
taxtech/urls.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
from django.urls import path, include
|
2 |
from rest_framework.routers import DefaultRouter
|
3 |
-
from .views import TaxTechAppViewSet, TaxLLMView, TaxDataViewSet, CompanyViewSet
|
4 |
|
5 |
router = DefaultRouter()
|
6 |
router.register(r'taxtechapp', TaxTechAppViewSet)
|
@@ -13,4 +13,6 @@ urlpatterns = [
|
|
13 |
# ... other URL patterns
|
14 |
path('taxdata/', include(router.urls)),
|
15 |
path('tax_llm_url/', TaxLLMView.as_view(), name='tax_llm_url'),
|
|
|
|
|
16 |
]
|
|
|
1 |
from django.urls import path, include
|
2 |
from rest_framework.routers import DefaultRouter
|
3 |
+
from .views import TaxTechAppViewSet, TaxLLMView, TaxDataViewSet, CompanyViewSet, TaxLLMTaxAddView
|
4 |
|
5 |
router = DefaultRouter()
|
6 |
router.register(r'taxtechapp', TaxTechAppViewSet)
|
|
|
13 |
# ... other URL patterns
|
14 |
path('taxdata/', include(router.urls)),
|
15 |
path('tax_llm_url/', TaxLLMView.as_view(), name='tax_llm_url'),
|
16 |
+
path('tax_llm_tax_add_url/', TaxLLMTaxAddView.as_view(), name='tax_llm_tax_add_url'),
|
17 |
+
|
18 |
]
|
taxtech/views.py
CHANGED
@@ -103,6 +103,75 @@ class TaxLLMView(APIView):
|
|
103 |
prompt = f"Hier sind weitere Daten: {api_data}. Bitte beantworten Sie die folgende Frage: {data['messages'][0]['prompt']}"
|
104 |
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
#prompt = data['messages'][0]['prompt']
|
107 |
# Specify model
|
108 |
#model = "pixtral-12b-2409"
|
|
|
103 |
prompt = f"Hier sind weitere Daten: {api_data}. Bitte beantworten Sie die folgende Frage: {data['messages'][0]['prompt']}"
|
104 |
|
105 |
|
106 |
+
#prompt = data['messages'][0]['prompt']
|
107 |
+
# Specify model
|
108 |
+
#model = "pixtral-12b-2409"
|
109 |
+
model = data['model']
|
110 |
+
print(model)
|
111 |
+
# Define the messages for the chat
|
112 |
+
messages = [
|
113 |
+
{
|
114 |
+
"role": "system",
|
115 |
+
"content": "Bitte geben Sie eine prägnante Antwort auf Deutsch. Geben Sie die Ausgabe in deutscher Sprache in menschlich gut verstaendlichen weise aus (mit Absaetzen etc.)."
|
116 |
+
},
|
117 |
+
{
|
118 |
+
"role": "user",
|
119 |
+
"content": [
|
120 |
+
{
|
121 |
+
"type": "text",
|
122 |
+
"text": prompt
|
123 |
+
}
|
124 |
+
]
|
125 |
+
}
|
126 |
+
]
|
127 |
+
|
128 |
+
if(isOnline):
|
129 |
+
api_key = os.environ["MISTRAL_API_KEY"]
|
130 |
+
|
131 |
+
# Initialize the Mistral client
|
132 |
+
client = Mistral(api_key=api_key)
|
133 |
+
|
134 |
+
|
135 |
+
# Get the chat response
|
136 |
+
chat_response = client.chat.complete(
|
137 |
+
model=model,
|
138 |
+
messages=messages
|
139 |
+
)
|
140 |
+
|
141 |
+
content = chat_response.choices[0].message.content
|
142 |
+
else:
|
143 |
+
content = "helloWorld"
|
144 |
+
|
145 |
+
print(content)
|
146 |
+
|
147 |
+
#print(chat_response.choices[0].message.content)
|
148 |
+
# Return the content of the response
|
149 |
+
return Response({"response": content})
|
150 |
+
except Exception as e:
|
151 |
+
print(f"An error occurred: {e}")
|
152 |
+
return Response({'error': 'Something went wrong'}, status=500)
|
153 |
+
|
154 |
+
class TaxLLMTaxAddView(APIView):
|
155 |
+
def post(self, request, format=None):
|
156 |
+
try:
|
157 |
+
# TODO - fix this path
|
158 |
+
response = requests.get('http://gaganyatri-django-spaces.hf.space/taxtech/taxdata/taxdata/')
|
159 |
+
|
160 |
+
# Check if the request was successful
|
161 |
+
if response.status_code == 200:
|
162 |
+
# The API response data is a JSON object
|
163 |
+
api_data = response.json()
|
164 |
+
#print(api_data)
|
165 |
+
|
166 |
+
data = request.data
|
167 |
+
|
168 |
+
#isOnline = data['isOnline']
|
169 |
+
isOnline = True
|
170 |
+
|
171 |
+
# Include the api_data in the prompt
|
172 |
+
prompt = f"Hier sind weitere Daten: {api_data}. Bitte beantworten Sie die folgende Frage: {data['messages'][0]['prompt']}"
|
173 |
+
|
174 |
+
|
175 |
#prompt = data['messages'][0]['prompt']
|
176 |
# Specify model
|
177 |
#model = "pixtral-12b-2409"
|