i wanna also ask why im facing the error in appwrite functions
Traceback (most recent call last): File "/usr/local/server/src/server.py", line 106, in action output = await asyncio.waitfor(execute(context), timeout=safeTimeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/asyncio/tasks.py", line 489, in waitfor return fut.result() ^^^^^^^^^^^^ File "/usr/local/server/src/server.py", line 91, in execute userModule = importlib.import_module("function." + userPath) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/importlib/__init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<frozen importlib._bootstrap>", line 1204, in _gcd_import File "<frozen importlib._bootstrap>", line 1176, in _find_and_load File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 690, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 940, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/usr/local/server/src/function/function.py", line 2, in <module> import tensorflow as tf ModuleNotFoundError: No module named 'tensorflow' even if i picked the Python ML 3.11 and wrote the install requirements in txt and when i check and download the code from deployment that appwrite chosen - everything is written ok, but i cant execute it
What's the code or part that throws the error?
import json import tensorflow as tf import numpy as np import pickle from flask import Flask, request, Response
`import json import tensorflow as tf import numpy as np import pickle from flask import Flask, request, Response
app = Flask(name)
Загрузка модели и токенайзера при старте приложения
model = tf.keras.models.load_model('text_model.h5') with open('tokenizer.pkl', 'rb') as f: tokenizer = pickle.load(f)
def generate_next_word(prompt): """ Генерация следующего слова на основе переданной строки prompt. """ # Преобразование текста в последовательность sequence = tokenizer.texts_to_sequences([prompt])[0] if len(sequence) < 5: padded = tf.keras.preprocessing.sequence.pad_sequences([sequence], maxlen=5) else: padded = np.array([sequence[-5:]])
# Предсказание следующего слова
prediction = model.predict(padded)
next_word_id = np.argmax(prediction)
# Поиск слова по индексу
for word, index in tokenizer.word_index.items():
if index == next_word_id:
return word
return ""
@app.route('/', methods=['POST']) def main(): """ Главная функция обработки POST-запроса. """ try: # Получаем данные от клиента data = request.get_json() prompt = data.get('prompt', '')
# Генерируем следующее слово
next_word = generate_next_word(prompt)
# Формируем JSON-ответ
response_data = {"next_word": next_word}
return Response(json.dumps(response_data, ensure_ascii=False), mimetype='application/json')
except Exception as e:
# Обработка ошибок
error_response = {"error": str(e)}
return Response(json.dumps(error_response, ensure_ascii=False), mimetype='application/json', status=500)
if name == "main": app.run(host='0.0.0.0', port=3000)`
Recommended threads
- [SOLVED] OAuth With Google & Flutter
Hi all, I'm trying to sign in with google and it all goes swimmingly until the call back. I get a new user created on the appwrite dashboard however the flutte...
- Custom emails
What happen if I use a third party email provider to customize my emails and my plan run out of emails/month? Appwrite emails are used as fallback sending emai...
- My organization's project is blocked
My organization's project is blocked so unblocked my organization then I will this