• Data/nlu.md o‘quv faylini yaratish
  • Dialog flow kutubxonasini o‘rnatish: pip install google-cloud-dialogflow Dialog oqimiga so‘rov yuborish uchun quyidagi koddan foydalanish
  • Image Recognition




    Download 5,69 Mb.
    bet16/182
    Sana19.05.2024
    Hajmi5,69 Mb.
    #244351
    1   ...   12   13   14   15   16   17   18   19   ...   182
    Bog'liq
    Python sun\'iy intellekt texnologiyasi Dasrlik 2024

    Rasa bilan integratsiya:
    Rasa-bu ochiq manbali chatbotlarni ishlab chiqish kutubxonasi. Rasa - dan foydalanish uchun Rasa-ni o‘rnatishingiz va konfiguratsiya faylini yaratishingiz kerak. Quyidagi misolda sizda Rasa allaqachon o‘rnatilgan deb taxmin qilinadi:
    Config konfiguratsiya faylini yarating.yml:
    language: en
    pipeline:
    - name: WhitespaceTokenizer
    - name: RegexFeaturizer
    - name: LexicalSyntacticFeaturizer
    - name: CountVectorsFeaturizer
    - name: CountVectorsFeaturizer
    analyzer: "char_wb"
    min_ngram: 1
    max_ngram: 4
    - name: DIETClassifier
    epochs: 100
    - name: EntitySynonymMapper
    - name: ResponseSelector
    epochs: 100
    Data/nlu.md o‘quv faylini yaratish:
    ## intent:greet
    - hey
    - hello
    - hi
    ## intent:goodbye
    - goodbye
    - bye
    - see you later
    Modelni o‘qitish:
    rasa train
    Chatbotni ishga tushirish:
    rasa run
    Dialog oqimi bilan integratsiya:
    Dialog flow-bu Google-ning bulutga asoslangan chatbot ishlab chiqish platformasi. Dialog flow-da loyiha yaratishingiz va API uchun kalitlarni olishingiz kerak.
    Dialog flow kutubxonasini o‘rnatish:
    pip install google-cloud-dialogflow
    Dialog oqimiga so‘rov yuborish uchun quyidagi koddan foydalanish:
    from google.cloud import dialogflow
    def detect_intent_text(project_id, session_id, text, language_code):
    session_client = dialogflow.SessionsClient()
    session = session_client.session_path(project_id, session_id)
    text_input = dialogflow.TextInput(text=text, language_code=language_code)
    query_input = dialogflow.QueryInput(text=text_input)
    response = session_client.detect_intent(
    request={"session": session, "query_input": query_input} )
    return response.query_result.fulfillment_text
    # Foydalanish misoli
    project_id = "your-project-id"
    session_id = "your-session-id"
    text = "Hello, how are you?"
    language_code = "en"
    response_text = detect_intent_text(project_id, session_id, text, language_code)
    print("Bot response:", response_text)
    “Sizning loyihangiz-id” va “sizning sessiyangiz-id” ni loyihangiz va sessiyangiz uchun mos qiymatlar bilan almashtirish.
    Ushbu ikkala misol shuni ko‘rsatadiki, siz Rasa va Dialogflow hujjatlariga muvofiq kerakli bog’liqliklar va hisoblarni o‘rnatganda.

      1. Download 5,69 Mb.
    1   ...   12   13   14   15   16   17   18   19   ...   182




    Download 5,69 Mb.