Skip to content

Commit

Permalink
Use OPENAI_KEY
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Nov 27, 2024
1 parent 9502b7b commit 1744f34
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ For compatibility with other code, these environment variables are honoured:
LANG: some handling of en_GB and en_US translating between then, fr_FR is a work in progress
OPENADDR_HOME: directory of data from http://results.openaddresses.io/
REDIS_SERVER: ip:port pair of where to cache geo-coding data
OPENAI_KEY: experimental: uses key from openai.com to enhance text

## Reference

Expand Down
16 changes: 15 additions & 1 deletion gedcom
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,11 @@ if($opts{'v'}) {
if($opts{'w'} || $opts{'B'} || $opts{'M'}) {
push @modules, 'Mozilla::CA';
}

if($ENV{'OPENAI_KEY'}) {
push @modules, 'OpenAIGPT4';
}

if($opts{'w'} && $opts{'c'}) {
# If you have a locally written module to look up entries,
# list them in gedcom.config,
Expand Down Expand Up @@ -905,6 +910,11 @@ if($opts{'w'}) {
die if(!defined($wills));
}

my $gpt;
if(my $key = $ENV{'OPENAI_KEY'}) {
$gpt = OpenAIGPT4->new($key);
}

my $meteo;

if($opts{'d'} && (!$opts{'r'}) && (!$opts{'O'})) {
Expand Down Expand Up @@ -7854,7 +7864,11 @@ sub print_person
$bio->append(conjunction(map { $_->as_string() } @phrases));
}
}
print $bio->rtrim()->as_string();
if($gpt) {
die 'TODO: ', $gpt->generate_text('Make this more readable ' . $bio->as_string(), 'gpt-3.5-turbo-1106');
} else {
print $bio->rtrim()->as_string();
}
if($opts{'w'} && (my $dbpedia = dbpedia({ person => $person, birth_dt => $birth_dt, yob => $yob, yod => $yod, birth_country => $birth_country }))) {
# FIXME: add citation
if($opts{'B'}) {
Expand Down

0 comments on commit 1744f34

Please sign in to comment.