示例#1
0
    except Exception:
        return "Internal error, please retry"


def service_now(date_str, state, count):
    if state == "close":
        state = "closed"
    date_str = date_str.title()
    snow_base = "https://vzbuilders.service-now.com/incident_list.do?sysparm_query="
    snow_state_urls = {
        "open": "stateIN1%2C-1%2C2&sysparm_first_row=1",
        "resolve":
        "resolved_atON{}@javascript:gs.beginningOf{}()@javascript:gs.endOf{}()",
        "create":
        "sys_created_onON{}@javascript:gs.beginningOf{}()@javascript:gs.endOf{}()",
        "closed":
        "closed_atON{}@javascript:gs.beginningOf{}()@javascript:gs.endOf{}()",
        "property": "%5Eu_responsible_property.name={}%5EORcmdb_ci.name={}"
    }
    #print(date_str, state, count)
    url = snow_base + snow_state_urls[state].format(date_str, date_str,
                                                    date_str)
    return url


first_question = "Hi, how are you?"
chat = Chat(
    os.path.join(os.path.dirname(os.path.abspath(__file__)),
                 "Example.template"))
chat.converse(first_question)
示例#2
0
def c(x):
    chat = Chat(pairs, reflections)
    return chat.converse(x)
示例#3
0
from chatbot import Chat,reflections,multiFunctionCall
import wikipedia,os

import warnings
warnings.filterwarnings("ignore")

def whoIs(query,sessionID="general"):
    try:
        return wikipedia.summary(query)
    except:
        for newquery in wikipedia.search(query):
            try:
                return wikipedia.summary(newquery)
            except:
                pass
    return "I don't know about "+query
        
    

call = multiFunctionCall({"whoIs":whoIs})
firstQuestion="Hi, how are you?"
chat = Chat(os.path.join(os.path.dirname(os.path.abspath(__file__)),"Example.template"), reflections,call=call)
chat.converse(firstQuestion)
#chat.save_template("test.template")
from chatbot import Chat, reflections, multiFunctionCall
import wikipedia, os

import warnings
warnings.filterwarnings("ignore")


def whoIs(query, sessionID="general"):
    try:
        return wikipedia.summary(query)
    except:
        for newquery in wikipedia.search(query):
            try:
                return wikipedia.summary(newquery)
            except:
                pass
    return "I don't know about " + query


call = multiFunctionCall({"whoIs": whoIs})
firstQuestion = "Hi, how are you? MY name is Gideon an A.I chatbot what can i do for you"
chat = Chat(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                         "examples/Example.template"),
            reflections,
            call=call)
chat.converse(firstQuestion)
import os


@register_call("increment_count")
def memory_get_set_example(session, query):
    name=query.strip().lower()
    # Get memory
    old_count = session.memory.get(name, '0')
    new_count = int(old_count) + 1
    # Set memory
    session.memory[name]=str(new_count)
    return f"count  {new_count}"


chat = Chat(os.path.join(os.path.dirname(os.path.abspath(__file__)), "get_set_memory_example.template"))
chat.converse("""
Memory get and set example

Usage:
  increment <name>
  show <name>
  remember <name> is <value>
  tell me about <name>

example:
  increment mango
  show mango
  remember sun is red hot star in our solar system
  tell me about sun
""")