File: target_fn.py

package info (click to toggle)
python-azure 20250603%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 851,724 kB
  • sloc: python: 7,362,925; ansic: 804; javascript: 287; makefile: 195; sh: 145; xml: 109
file content (37 lines) | stat: -rw-r--r-- 1,246 bytes parent folder | download
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
32
33
34
35
36
37
def target_fn(query: str) -> str:
    """An example target function."""
    if "LV-426" in query:
        return {"response": "There is nothing good there."}
    if "central heating" in query:
        return {"response": "There is no central heating on the streets today, but it will be, I promise."}
    if "strange" in query:
        return {"response": "The life is strange..."}


def target_fn2(query: str) -> str:
    response = target_fn(query)["response"]
    return {"response": response}


def target_fn3(query: str) -> str:
    response = target_fn(query)
    response["query"] = f"The query is as follows: {query}"
    return response


def target_multimodal_fn1(conversation) -> str:
    if conversation is not None and "messages" in conversation:
        messages = conversation["messages"]
        messages.append(
            {
                "role": "assistant",
                "content": [
                    {
                        "type": "image_url",
                        "image_url": {"url": "https://cdn.britannica.com/68/178268-050-5B4E7FB6/Tom-Cruise-2013.jpg"},
                    }
                ],
            }
        )
        conversation["messages"] = messages
    return {"conversation": conversation}