This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from openai_function_call import openai_function | |
import guidance | |
@openai_function | |
def get_weather(location: str, unit: str = 'fahrenheit', date: str = 'today'): | |
""" Get the current weather in a given location and date.""" | |
weather_info = { | |
'location': location, | |
'unit': unit, | |
'temperature': '60' if unit == 'fahrenheit' else '15', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pydantic import BaseModel, Field | |
from tenacity import retry, stop_after_attempt | |
class FakeGoogleSearch(BaseModel): | |
query: str = Field(..., description='The query of Google search') | |
class FakeGoogleSearchResponse(BaseModel): | |
result: str = Field(..., description='The search result') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
def main(): | |
base_url = "https://pubmlst.org/bigsdb?db=pubmlst_saureus_seqdef&page=downloadAlleles&locus=" | |
for number in xrange(1, 2940): | |
# i.e. SAUR0001 | |
file = "SAUR" + '{:0>4}'.format(number) | |
filename = file + '.fas' | |
url = base_url + file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
class 我: | |
def __init__(本我, 愿意付出的时间): | |
本我.愿意付出的时间 = 愿意付出的时间 | |
本我.武力值 = 5 | |
def 学习(本我, 宝典): | |
本我.武力值 += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Database: | |
def __init__(self): | |
self.database = {} | |
self.msgs = { | |
-1: 'INVALID COMMAND', | |
0: 'OK', | |
1: 'MISSING VALUE', | |
2: 'NOT FOUND', | |
3: 'TRUE', | |
4: 'FALSE', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string = ''' | |
<h1>{{customerName}}</h1> | |
<ul> | |
{% for user in users %} | |
<li><a href="{{ user.url }}">{{ user.username }} {{location.CA}}</a></li> | |
{% endfor %} | |
</ul> | |
''' | |
dict_ = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Sequence | |
class Request: | |
def __init__(self, id): | |
self.id = str(id) | |
def __str__(self): | |
return '[Request: %s]' % self.id | |
class Response: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Helpers start | |
class TreeNode: | |
def __init__(self, val): | |
self.val = val | |
self.left = self.right = None | |
def get_tree(): | |
''' | |
4 | |
/ \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def find_equal_subsets(self, arr): | |
""" | |
@param: arr: List[str] | |
@return: Tuple | |
""" | |
total = sum(arr) | |
# if half subsets value exist | |
if total % 2 != 0: | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SegmentTreeNode: | |
def __init__(self, st, ed, mval): | |
self.st = st | |
self.ed = ed | |
self.min = mval | |
class SegmentTree: | |
def __init__(self, arr): | |
if not arr: | |
raise 'Empty input array' |
NewerOlder