This file contains hidden or 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 json | |
import time | |
from typing import Dict, List, Any | |
from galileo.experiments import run_experiment | |
from dotenv import load_dotenv | |
from galileo import galileo_context | |
load_dotenv("../.env") | |
This file contains hidden or 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
on: | |
pull_request: | |
types: [opened] | |
jobs: | |
comment: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/github-script@v5 | |
with: |
This file contains hidden or 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
# pip install openai retry | |
import openai | |
from retry import retry | |
model="curie:ft-xxx-2021-01-09-19-21-20 | |
@retry(Exception, tries=3, delay=10) | |
def get_gpt_reason(prompt, model, prob=False, max_tokens=10): | |
This file contains hidden or 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
def fbeta_harmonic_mean(metric1: float, metric2: float, beta: float): | |
""" Return harmonic mean giving more importance to one metric | |
metric1: metric1 value | |
metric2: metric2 value | |
beta : The strength of metric2 versus metric1 in the F-score. | |
""" | |
beta2 = beta ** 2 | |
denom = beta2 * metric1 + metric2 | |
f_score = (1 + beta2) * metric1 * metric2 / denom | |
return f_score |
This file contains hidden or 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 googletrans import Translator | |
from google.cloud import translate_v2 as translate | |
from textblob import TextBlob | |
class CustomTranslator: | |
def __init__(self, target='en'): | |
self.target = target | |
self.set_free_client() | |
self.set_google_client() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 re, inspect | |
# Taken and modified from https://github.com/fastai/fastcore | |
class Base: | |
def _store_attr(self, **attrs): | |
for n,v in attrs.items(): | |
setattr(self, n, v) | |
self.__stored_args__[n] = v |
This file contains hidden or 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
# Remove old version | |
brew uninstall elasticsearch-full | |
rm -rf /usr/local/var/lib/elasticsearch/ | |
rm -rf /usr/local/var/log/elasticsearch/elasticsearch_account.log | |
rm -rf /usr/local/var/elasticsearch/plugins/ | |
rm -rf /usr/local/etc/elasticsearch/ | |
brew uninstall kibana-full | |
rm -rf /usr/local/var/lib/kibana/ | |
rm -rf /usr/local/var/kibana/plugins/ |
This file contains hidden or 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
PUT /test_index | |
{ | |
"mappings": { | |
"properties": { | |
"title": { | |
"type": "text", | |
"analyzer": "synonym_analyzer", | |
"search_analyzer": "synonym_analyzer" | |
}, |
This file contains hidden or 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
# https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-synonym-tokenfilter.html | |
# Explicit mappings match any token sequence on the LHS of "=>" | |
# and replace with all alternatives on the RHS. These types of mappings | |
# ignore the expand parameter in the schema. | |
# Examples: | |
i-pod, i pod => ipod, | |
sea biscuit, sea biscit => seabiscuit | |
# Equivalent synonyms may be separated with commas and give | |
# no explicit mapping. In this case the mapping behavior will |
NewerOlder